Page 1 of 1

Multiple Forms Submission in PHP

Posted: Mon Nov 18, 2013 11:47 pm
by vipinsaini
Hello....

Actually i have multiple forms on a single web page and i want to submit these forms for further processing into database, but unfortunately, the submit button of forms are not working...
I am using dreamwever and even dreamweaver editor is not showing any kind of error...
So could someone help me to resolve this..
Here is my PHP and HTML code...

Code: Select all

<?php  include('config/setup.php'); ?>
<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title><?php include('title.php'); ?></title>
        <?php include('header.php'); ?>
        <script src="http://code.jquery.com/jquery-1.6.3.min.js"></script>
        <link href="css/default.css" rel="stylesheet" type="text/css" />
<!--        <script src="js/registration/jquery.js" type="text/javascript"></script>-->
        <script src="js/registration/validate.min.js" type="text/javascript"></script>
        <script src="js/registration/init.js" type="text/javascript"></script>
        <script>
            $(document).ready(function() {
                $("#content div").hide(); // Initially hide all content
                $("#tabs li:first").attr("id","current"); // Activate first tab
                $("#content div:first").fadeIn(); // Show first tab content
    
                $('#tabs a').click(function(e) {
                    e.preventDefault();
                    $("#content div").hide(); //Hide all content
                    $("#tabs li").attr("id",""); //Reset id's
                    $(this).parent().attr("id","current"); // Activate this
                    $('#' + $(this).attr('title')).fadeIn(); // Show content for current tab
                });
            })();
        </script>
    </head>

    <body id="subpage">
        <div class="wrapper">
            <div class="header">
             <?php $page = 'eight';
                  include('menu.php');
				  $dbfname ='';
				  $dblname = '';
				  $dbusername ='';
				  $dbemail = '';
				  $dbcountry = '';
				  $dbtradingexperience='';
				  $dbbio ='';
				  $dbtradingstyle = '';
				  $dbmotto = '';
				  $dbavatar = '';
				  $error_status="";
				  if(isset($_SESSION['email']))
				  {
			    	$q ="SELECT * FROM  tbluserregistration  WHERE email='$_SESSION[email]'";
					$r = mysqli_query($dbc, $q);  
					$user = mysqli_fetch_assoc($r);
				    $dbfname = $user['fname'];
					$dbcurrentpassword = $user['password'];
				    $dblname = $user['lname'];
					$dbusername = $user['username'];
					$dbemail = htmlentities($user['email']);
					$dbcountry = $user['country'];
					$dbtradingexperience = $user['experience'];
					$dbbio = $user['bio'];
					$dbtradingstyle = $user['tradingstyle'];
					$dbmotto = $user['motto'];
				    $error_status= mysqli_error($dbc);
				 }
				 else
				 {
						echo "<script type=\"text/javascript\">"; 
						echo "alert('Please Login First!!')"; 
						echo "</script>";
			     }
				//echo "befor login check hello";
				 if(isset($_SESSION['email']) && isset($_POST['submit']))
				 {
					 if(isset($_POST['userprofile']))
					 {
						 //echo "tab1 is clicked!!";
							
							//for storing the image into images folder
								$email = htmlentities($_SESSION['email']);
							    $fname = htmlentities($_POST['firstname']);
								$lname = htmlentities($_POST['lastname']);
								$country = htmlentities($_POST['country']);
								$tradingexperience = htmlentities($_POST['experience']);
								$bio = htmlentities($_POST['bio']);
								$tradingstyle = htmlentities($_POST['tradingstyle']);
								$motto = htmlentities($_POST['motto']);
								// name of the file
								$pic = ($_FILES['photo']['name']);
   							    $error_status ='Profile Update Success '.mysqli_error($dbc);
								$target = "images/"; 
 								$target = $target . basename( $_FILES['photo']['name']);
				$tab1query = "update  tbluserregistration set fname='$fname', lname='$lname',
								country='$country', experience ='$tradingexperience', bio ='$bio',
								tradingstyle = '$tradingstyle' ,motto = '$motto', avatar = '$pic'
								where   email = '$email'"; 
								$tab1fetch = mysqli_query($dbc,$tab1query);
								 //Writes the photo to the server 
								 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
								 { 
								//Tells you if its all ok 
								 echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; 
								 } 
								 else
								  { 
								 //Gives and error if its not 
								 echo "Sorry, there was a problem uploading your file."; 
								  } 
								   if(!$tab1fetch )
									{
									 die("Query is not being executed,so first check your mysql query");
									}
									echo "You have successfully updated your profile!!";
							 
					 }
					 else if(isset($_POST['tab2']))
					 {
						 if(isset($_POST['passwordchange']))
						 {
							 								
								echo "tab passwordchange is clicked!!";
								$currentpassword = $_POST['currentpassword'];
								$newpassword = $_POST['newpassword'];
								$confirmpassword = $_POST['confirmpassword'];
								
								if($dbcurrentpassword == $currentpassword)
								{
								   if($newpassword==$confirmpassword)
							       {
									$updatequery = "UPDATE tbluserregistration SET password='$newpassword'
									 WHERE email='$email'";
									$row1 = mysqli_query($dbc,$updatequery);
										if(!$row1 )
										{
										 die("Query is not being executed,so first check your mysql query");
										}
										echo "<h1><style='color:white;'>Password is Updated Successfully!!</h1>";
										}else
										{
											echo "NewPasword/ConfirmPassword Combination is Wrong";
										}
								    }
									else
									{
										echo "Check Your Current Password";
									}
							       
						        }
								//echo "end of the password change tab";
					 }
						 }
						 else if(isset($_POST['emailchange']))
						 {
							 echo "tab emailchange is clicked!!";
									
									$emailpassword = $_POST['emailpassword'];
									$emailchange = $_POST['emailchange'];
									
									if($dbcurrentpassword == $emailpassword)
										{
										$ecquery = "UPDATE tbluserregistration SET email='$emailchange' where email='$email'";
										mysqli_query($dbc,$ecquery);
										echo mysqli_error($dbc);
										echo "<h1><style='color:white;'>Email is Updated Successfully!!</h1>";
										
										//echo "befor tab3 button clicked";
										}
									 else
										  { 
										  echo "<h1><style='color:white;'>Current Password is Wrong!!</h1>";
										  }
								
					 }
					 else if(isset($_POST['accountpage']))
					 {
						 echo "tab3 is clicked!!";
							
							$broker = $_POST['broker'];
							$server = $_POST['server'];
							$investerpassword = $_POST['investerpassword'];
							$accountname = $_POST['accountname'];
							$briefdescription = $_POST['briefdescription'];
							$systemtype = $_POST['systemtype'];
							$tradingtype = $_POST['tradingtype'];
							$accounttype = $_POST['accounttype'];
							$leveragetype = $_POST['leveragetype'];
							$lastactivity = $_POST['lastactivity'];
							
							$tab3query = "INSERT INTO tblaccount (company,server,investerpass,accountname,
							briefdesc,systemtype,tradingtype,type,leverage,hislastupdate) VALUES 
							('$broker','$server', '$investerpassword','$accountname', '$briefdescription',
							'$systemtype ','$tradingtype','$accounttype','$leveragetype','$lastactivity')";
							
							$tab3fetch = mysqli_query($dbc,$tab3query);
							echo mysqli_error($dbc);
							//echo $tab3fetch ;
							echo "Your Data is Saved Successfully!!";	

						 
					 
				 }
					
					  
				 
			?>
            </div>
            <div class="section">
                <div class="logoposition subpagelogoposition">
                    <div class="logo"><a href="#"><img src="images/logo_1.png" /></a></div>
                </div>
                <div id="slider">

                </div>

                <div class="middlebanner"></div>

                <div class="cleaner"></div>
                <div class="container">
                    <div class="matter">
                         <h2><?php echo $error_status; ?></h2>
                        <div class="subpagescontent">
                            <div class="dashboard">
                                <h3>Settings</h3>
                                <div class="advancestatic">
            <ul id="tabs">
            <li><a href="#" style="font-size: 18px" title="tab1"> Profile </a></li>
            <li><a href="#" style="font-size: 18px" title="tab2"> Password </a></li>
            <li><a href="#" style="font-size: 18px" title="tab3"> Account </a></li>
            </ul>
            <div id="content">
<div id="tab1">
<br/><br/>
            <fieldset style="border:1 px; width:90%; ">
            <legend style="font-size:20px; font-weight:bold;">Update Profile</legend><br>
            <form id="form" class="blocks" action="settings.php" method="post">
            <article>
            <label >Username:</label>
            <label  ><?php echo $dbusername;?></label>
            </article><br><br>
            <article >
            <label style="margin-left:-330px;">Email:</label>
            <label style="margin-left:-150px;" ><?php echo $dbemail;?></label>
            </article><br><br>
            <article>
            <label >First Name:</label>
            <input type="text" class="text1" name="firstname" value="<?php echo $dbfname; ?>" />
            </article>
            <article>
            <label>Last name:</label>
            <input type="text" class="text1" name="lastname" value="<?php echo $dblname; ?>" />
            </article>
            <article>
            <label>Country:</label>
            <select name="country" class="text1" id="country"  >
            <option selected="selected" value="<?php if($dbcountry!="")echo $dbcountry; else echo ''?>" >
			<?php if($dbcountry!="")echo $dbcountry; else echo 'Select country'?></option>
            <option value='Albania'>Albania</option>
            <option value='Algeria'>Algeria</option>
            <option value='American-Samoa'>American-Samoa</option>
            </select>
            </article>
             <article>
            <label>Trading Experience:</label>
            <select name="experience" class="text1" id="experience"  >
            <option selected="selected" value="<?php if($dbtradingexperience!="")echo $dbtradingexperience; else echo ''?>" >
			<?php if($dbtradingexperience!="")echo $dbtradingexperience; else echo 'Select experience'?></option>
            <option value='Albania'>Albania</option>
            <option value='Algeria'>Algeria</option>
            <option value='American-Samoa'>American-Samoa</option>
            </select>
            </article>
            <article>
            <label>Bio :</label>
            <textarea class="" cols="27" rows="8" name="bio"><?php echo $dbbio ?>

Re: Multiple Forms Submission in PHP

Posted: Tue Nov 19, 2013 1:12 am
by requinix
I don't see any submit buttons in there. In fact it looks like the code may have been cut off?