Trouble in entering data in php database.?
-
First i am giving an overview of what i am trying to do. I am creating a home page with register button.The registration is a 3 step process.On clicking register a page (1st form) with next button pop downs (using jquery) asking details.On clicking next second page (2nd form) pop down (using jquery) asking for more details and similarly a third page. My problem is on clicking next data from 1st form should be extracted as well as the second page should pop down.I am able to extract data but the second page donot pops down. Similarly clicking the next button of second page should store data of 1st and 2nd form in database but should also pop third page. Here i am providing with the 3 pop down pages. <div id="box_bg"> <div class="box" id="box"> <a class="boxclose" id="boxclose"></a> <div id="cont"> <div id="c_img"> <div id="i_bot"></div> <div id="i_mid"></div> <div id="i_top"></div> <div id="i_slide"> <Div id="cont_txt"> <div id="frm" class="bor"> <form id="whi" action="" method="post"> <table> <tr><td>First Name </td></tr> <tr><td> <input type="text" value="fame" name="fname" id="fname" class="bor"><br> </td></tr> <tr><td>Last Name </td></tr> <tr><td><input type="text" value="lname" name="lname" id="lname" class="bor"><br></td></tr> <tr><td>E-Mail </td></tr><tr><td> <input type="text" value="[email protected]" name="email" id="email" class="bor"><br> </td></tr> <tr><td> <input type="submit" value="next" name="next" id="nxt_bt" class="nxt_but" /><br> </td></tr></table> </form> </div></div></div> <div id="i_slide2"> <?php if(isset($_POST['next'])) { $fname=$_POST["fname"]; $lname=$_POST["lname"]; $mail=$_POST["email"]; //echo $fname."<br>"; } ?> <div id="cont_txt"> <form id="whi" action="" method="post"> <table><tr><td>Username </td></tr><tr><td> <input type="text" value="Username" id="cid1" class="bor" name="cid"><br> </td></tr> <tr><td>Password </td></tr> <tr><td><input type="password" value="Password" id="pswd" class="bor" name="psswrd"><br></td></tr> <tr><td>Retype Password </td></tr> <tr><td><input type="password" id="cpswd" value="udit1234" name="cpsswrd" class="bor"><br> </td></tr> <tr><td> <input type="submit" value="next" name="next2" id="nxt_bt2" class="nxt_but2" /><br> </td></tr></table> </form> </div></div> <div id="i_slide3"> <?php if(isset($_POST['next2'])) { $cid=$_POST['cid']; $psswrd=$_POST['psswrd']; $cpsswrd=$_POST['cpsswrd']; mysql_connect("localhost", "root", "") or die("Unable to connect to MySQL"); echo "Connected!!<br>"; mysql_select_db("login") or die ("No such Database Found"); mysql_query("CREATE TABLE log( fname VARCHAR(30) NOT NULL, lname VARCHAR(30) NOT NULL, mail VARCHAR(30) NOT NULL, cid VARCHAR(30) NOT NULL, psswrd VARCHAR(30) NOT NULL, cpsswrd VARCHAR(30) NOT NULL, PRIMARY KEY(cid,mail))") or die("table not created<br>".mysql_error()); echo "Table Created!<br>"; $check=mysql_query("insert into log values('$fname','$lname','$mail','$cid',… if($check) echo "inserted <br>"; else echo "insertion error <br>".mysql_error(); } ?> <div id="cont_txt"> <div id="whi2&q Additional Details <div id="whi2"> You Have Successfully Registered on our Website !! <input type="button" value="Generate XML" name="next3" id="nxt_bt3" class="nxt_but3"/> </div></div&g
-
Answer:
I'm not sure, but you can try to change the "action" attribute of each form: eg: <form id="whi" action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> When you click on the next button, the form generate a post request and recharge the form. You can print the form directly by php. Your code will be like this: ----------------------CODE------------… <div id="box_bg"> <div class="box" id="box"> <a class="boxclose" id="boxclose"></a> <div id="cont"> <div id="c_img"> <div id="i_bot"></div> <div id="i_mid"></div> <div id="i_top"></div> <?php if(!isset($_POST) && empty($_POST) { ?> <div id="i_slide"> <div id="cont_txt"> <div id="frm" class="bor"> <form id="whi" action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr><td>First Name </td></tr> <tr><td> <input type="text" value="fame" name="fname" id="fname" class="bor"><br> </td></tr> <tr><td>Last Name </td></tr> <tr><td><input type="text" value="lname" name="lname" id="lname" class="bor"><br></td></tr> <tr><td>E-Mail </td></tr><tr><td> <input type="text" value="[email protected]" name="email" id="email" class="bor"><br> </td></tr> <tr><td> <input type="submit" value="next" name="next" id="nxt_bt" class="nxt_but" /><br> </td></tr></table> </form> </div></div></div> <?php } if(isset($_POST['next']) && !empty($_POST['next'])) { $fname=$_POST["fname"]; $lname=$_POST["lname"]; $mail=$_POST["email"]; //echo $fname."<br>"; ?> <div id="i_slide2"> <div id="cont_txt"> <form id="whi" action="" method="post"> <table><tr><td>Username </td></tr><tr><td> <input type="text" value="Username" id="cid1" class="bor" name="cid"><br> </td></tr> <tr><td>Password </td></tr> <tr><td><input type="password" value="Password" id="pswd" class="bor" name="psswrd"><br></td></tr> <tr><td>Retype Password </td></tr> <tr><td><input type="password" id="cpswd" value="udit1234" name="cpsswrd" class="bor"><br> </td></tr> <tr><td> <input type="submit" value="next" name="next2" id="nxt_bt2" class="nxt_but2" /><br> </td></tr></table> </form> </div></div> <?php } ?> <?php if(isset($_POST['next2']) && !empty($_POST['next'])) { $cid=$_POST['cid']; $psswrd=$_POST['psswrd']; $cpsswrd=$_POST['cpsswrd']; mysql_connect("localhost", "root", "") or die("Unable to connect to MySQL"); echo "Connected!!<br>"; mysql_select_db("login") or die ("No such Database Found"); mysql_query("CREATE TABLE log( fname VARCHAR(30) NOT NULL, lname VARCHAR(30) NOT NULL, mail VARCHAR(30) NOT NULL, cid VARCHAR(30) NOT NULL, psswrd VARCHAR(30) NOT NULL, cpsswrd VARCHAR(30) NOT NULL, PRIMARY KEY(cid,mail))") or die("table not created<br>".mysql_error()); echo "Table Created!<br>"; $query = mysql_query("insert into log values('$fname','$lname','$mail','$cid',… $count = mysql_num_rows($query); if($count != 1){ ?> <div id="i_slide3"> <div id="cont_txt"> <div id="whi2&q Additional Details <div id="whi2"> You Have Successfully Registered on our Website !! <input type="button" value="Generate XML" name="next3" id="nxt_bt3" class="nxt_but3"/> </div> <?php } else{ echo "insertion error <br>".mysql_error(); } ?> </div> -------------CODE-END------------- If you have errors, send me an email here: [email protected]
ele at Yahoo! Answers Visit the source
Related Q & A:
- What is the best data model and database systems to store social graph?Best solution by Quora
- How to parse .log file and insert into database in PHP?Best solution by unix.com
- How can I insert posted data into the database?Best solution by Stack Overflow
- How to protect data in SQLite database?Best solution by Stack Overflow
- How to store data in php and get data from php?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.