submit button

Reply

Join Date: Feb 2008
Posts: 58
Reputation: zanzo is an unknown quantity at this point 
Solved Threads: 0
zanzo's Avatar
zanzo zanzo is offline Offline
Junior Poster in Training

submit button

 
0
  #1
Mar 3rd, 2008
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:
  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>
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 66
Reputation: silviuks is an unknown quantity at this point 
Solved Threads: 11
silviuks silviuks is offline Offline
Junior Poster in Training

Re: submit button

 
0
  #2
Mar 3rd, 2008
maybe on yhe 3rd page after processing the data you also insert into database.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 58
Reputation: zanzo is an unknown quantity at this point 
Solved Threads: 0
zanzo's Avatar
zanzo zanzo is offline Offline
Junior Poster in Training

Re: submit button

 
0
  #3
Mar 3rd, 2008
actually nope
also there is no code php
only html
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 11
Reputation: coffeepot! is an unknown quantity at this point 
Solved Threads: 2
coffeepot!'s Avatar
coffeepot! coffeepot! is offline Offline
Newbie Poster

Re: submit button

 
0
  #4
Mar 3rd, 2008
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.
Anything one man can make - another man will try to break.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: submit button

 
0
  #5
Mar 3rd, 2008
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.:
  1. if(isset($_POST['submit']) && isset($_POST['smoke'])){
  2. //insert into the db
  3. }
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 58
Reputation: zanzo is an unknown quantity at this point 
Solved Threads: 0
zanzo's Avatar
zanzo zanzo is offline Offline
Junior Poster in Training

Re: submit button

 
0
  #6
Mar 4th, 2008
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:

  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>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: submit button

 
0
  #7
Mar 4th, 2008
Not exactly sure what you are asking. You want to hide the delete button? If so, use css:
  1. <input name="delete" id="delete" type="submit" value="Delete User" onClick="return checkDelete();" <?php if(some condition){echo "style='display:none'"; }?> />
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 58
Reputation: zanzo is an unknown quantity at this point 
Solved Threads: 0
zanzo's Avatar
zanzo zanzo is offline Offline
Junior Poster in Training

Re: submit button

 
0
  #8
Mar 4th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: submit button

 
0
  #9
Mar 4th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 58
Reputation: zanzo is an unknown quantity at this point 
Solved Threads: 0
zanzo's Avatar
zanzo zanzo is offline Offline
Junior Poster in Training

Re: submit button

 
0
  #10
Mar 4th, 2008
this will hide the button delete, when the page is loaded
but what i want is to hide it after clicking this button
okay!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC