943,634 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5804
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 3rd, 2008
0

submit button

Expand Post »
hello,
i have a serious problem

i have 4 pages
1st page: user enters his first, middle and last name. + a submit button to the 2nd page
2nd page: he enters his Gender, Age and Marital status. + a submit button to the 3rd page
3rd page: Address, City and Country + a submit button to the 4th page
4th page: he is asked some questions, + a submit button to insert data into Database
The problem is that the data is entered to db, after loading page 4, and not when clicking the submit button. So the data entered in page 4 are not entered to db

so what could i do to resolve this problem
plz help
This is the code of page4.php:
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3. $Fname = $_SESSION['fname'];
  4. $Mname = $_SESSION['mname'];
  5. $Lname = $_SESSION['lname'];
  6. $Gender = $_SESSION['gender'];
  7. $Age = $_SESSION['age'];
  8. $Mstatus = $_SESSION['mstatus'];
  9. $Address = $_SESSION['address'];
  10. $City = $_SESSION['city'];
  11. $Country = $_SESSION['country'];
  12. ?>
  13.  
  14. <html>
  15. <head><title> Registration page four </title></head>
  16. <body>
  17.  
  18. <?php
  19. // insert data to db
  20. ?>
  21.  
  22. <form name="page4form" method="post" action="registered.php">
  23.  
  24. <p> In order to register to our website, you should fill this information: </p>
  25. <table width ="500" border ="0" cellpadding = "2" cellspacing ="0">
  26. <tr>
  27. <td colspan="2">&nbsp;</td>
  28. </tr>
  29.  
  30. <tr>
  31. <td width="200">a. Do you smoke?</td>
  32. <td>
  33. <input name="smoke" type="radio" id="smoke" value="Y">yes<br>
  34. <input name="smoke" type="radio" id="smoke" value="N">No<br>
  35. </td>
  36. </tr>
  37. <tr align="center">
  38. <td colspan="2"><input name="submit" type="submit" value="Register"></td>
  39. </tr>
  40. </table>
  41. </form>
  42.  
  43. </body>
  44. </html>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
zanzo is offline Offline
58 posts
since Feb 2008
Mar 3rd, 2008
0

Re: submit button

maybe on yhe 3rd page after processing the data you also insert into database.
Reputation Points: 10
Solved Threads: 15
Junior Poster in Training
silviuks is offline Offline
95 posts
since Apr 2006
Mar 3rd, 2008
0

Re: submit button

actually nope
also there is no code php
only html
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
zanzo is offline Offline
58 posts
since Feb 2008
Mar 3rd, 2008
0

Re: submit button

How about carrying the data over to a 5th page and if the data goes into the database give a nice happy message, if the data fails here, you can warn the user and send them back to the beginning.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
coffeepot! is offline Offline
11 posts
since Feb 2008
Mar 3rd, 2008
0

Re: submit button

Your php insert is happening as page 4 loads. Move the insert up to the top with the rest of the php. Also, surround the insert with a conditional to check if the smoke button has been selected
and the submit button has been pushed i.e.:
php Syntax (Toggle Plain Text)
  1. if(isset($_POST['submit']) && isset($_POST['smoke'])){
  2. //insert into the db
  3. }
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Mar 4th, 2008
0

Re: submit button

fine, that's work, thanks alot
but i do have some other problem:

in a page, i have 2 button one for delete and other for update
as for the update i link the user to another page, im ok with that
but for the delete, who would i hide the button delete and update
this is the code:

PHP Syntax (Toggle Plain Text)
  1. $action = $_POST['action'];
  2. if ($action==0) //present the form
  3. {
  4. ?>
  5. <form name="updateform" action = "update.php?ID=<?php echo $ID; ?>" method="post"> <input type="hidden" name="action" value="update">
  6. <input name="update" type="submit" value="Update User Data"></div>
  7. </form>
  8.  
  9. <form name="deleteform" method="post" action="<? echo $_SERVER['PHP_SELF']?>">
  10. <input type="hidden" name="action" value="delete">
  11. <input name="delete" id="delete" type="submit" value="Delete User" onClick="return checkDelete();" >
  12.  
  13. <?php
  14. }
  15. if (($action=="delete") && isset($_POST['delete'])) // so the delete button is pressed
  16. {
  17. // delete user
  18. ?>
  19. <a href="registered.php"> Back to registered users</a>
  20. <?php
  21. }
  22. ?>
  23. </form>
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
zanzo is offline Offline
58 posts
since Feb 2008
Mar 4th, 2008
0

Re: submit button

Not exactly sure what you are asking. You want to hide the delete button? If so, use css:
php Syntax (Toggle Plain Text)
  1. <input name="delete" id="delete" type="submit" value="Delete User" onClick="return checkDelete();" <?php if(some condition){echo "style='display:none'"; }?> />
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Mar 4th, 2008
0

Re: submit button

i want to remove the button update and delete

i used <div style="display:"><input type="submit" name="delete" onClick= "return checkdelete()></div>

and in the checkdelete() i ask him to style="display:none"

but it doesn't work
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
zanzo is offline Offline
58 posts
since Feb 2008
Mar 4th, 2008
0

Re: submit button

What about this:
<div style="display:none"><input type="submit" name="delete" onclick= "return checkdelete()" /></div>
Last edited by buddylee17; Mar 4th, 2008 at 3:30 pm.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Mar 4th, 2008
0

Re: submit button

this will hide the button delete, when the page is loaded
but what i want is to hide it after clicking this button
okay!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
zanzo is offline Offline
58 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Navigation help please
Next Thread in PHP Forum Timeline: I need to embed stock live charts in website





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC