hello,
i have a serious problem :S

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 
	 session_start();
      $Fname = $_SESSION['fname'];
      $Mname = $_SESSION['mname'];
      $Lname = $_SESSION['lname'];
      $Gender = $_SESSION['gender'];
      $Age = $_SESSION['age'];     
      $Mstatus = $_SESSION['mstatus'];
      $Address = $_SESSION['address'];
      $City = $_SESSION['city'];
      $Country = $_SESSION['country'];
?>
	
<html>
<head><title> Registration page four </title></head>
<body>

<?php
   // insert data to db
?>
					
 <form name="page4form" method="post" action="registered.php">
	 	
<p> In order to register to our website, you should fill this information: </p>
<table width ="500" border ="0" cellpadding = "2" cellspacing ="0">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
			
<tr> 
<td width="200">a. Do you smoke?</td>
<td>
<input name="smoke" type="radio" id="smoke" value="Y">yes<br>
 <input name="smoke" type="radio" id="smoke" value="N">No<br>
 </td>
</tr>
<tr align="center"> 
<td colspan="2"><input name="submit" type="submit" value="Register"></td>
 </tr>  
  </table>
 </form> 
  
</body>
</html>

Recommended Answers

All 15 Replies

maybe on yhe 3rd page after processing the data you also insert into database.

actually nope :S
also there is no code php
only html

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.

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.:

if(isset($_POST['submit']) && isset($_POST['smoke'])){
//insert into the db
}

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:

$action = $_POST['action'];
if ($action==0) //present the form
 {        	 
?>		
<form name="updateform" action = "update.php?ID=<?php echo $ID; ?>" method="post">   <input type="hidden" name="action" value="update">
   <input name="update" type="submit" value="Update User Data"></div>
</form>
	
<form name="deleteform"  method="post" action="<? echo $_SERVER['PHP_SELF']?>">	
    <input type="hidden" name="action" value="delete">
    <input name="delete" id="delete" type="submit" value="Delete User" onClick="return checkDelete();" >
	
<?php 	
 } 
 if (($action=="delete") && isset($_POST['delete'])) // so the delete button is pressed
   {      
      // delete user   
    ?>
    <a href="registered.php"> Back to registered users</a>
    <?php    
  }
   ?>
</form>

Not exactly sure what you are asking. You want to hide the delete button? If so, use css:

<input name="delete" id="delete" type="submit" value="Delete User" onClick="return checkDelete();" <?php if(some condition){echo "style='display:none'"; }?> />

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 :S

What about this: <div style="display:none"><input type="submit" name="delete" onclick= "return checkdelete()" /></div>

this will hide the button delete, when the page is loaded
but what i want is to hide it after clicking this button
okay!

Gotcha! <input type="submit" name="delete" onclick="this.style.display='none';" />

Or to just disable the button: <input type="submit" name="delete" onclick="this.disabled='disabled';" />

it looks goood but i have another method onclick:

is this code right:
<input type="submit" name="delete" onclick="this.disabled='disabled'; return checkdelete()" />
?

Not too sure about that. What I would do is put an onsubmit action in the form element.
<form name="deleteform" method="post" action="<? echo $_SERVER?>" onsubmit="return checkdelete();">

thx buddley :D, i agree with that

badly it doesn't work :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.