Simple PHP Form not echoing variables to next page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jma6517
Forum Newbie
Posts: 1
Joined: Wed Apr 01, 2009 11:57 am

Simple PHP Form not echoing variables to next page

Post by jma6517 »

Any help would be VERY MUCH appreciated!

I have a form (page1.php)that needs to post information to page2.php. After the user accepts the disclaimer and hits submit on page2.php, the form information is sent to an email address. The problem that I am having is that the information that the user filled in the form on page1.php is not showing up on page2.php.
:banghead:


Here is page1.php:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
  <head>
  <title>Page 1</title>
 <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
<body bgcolor=#ffffff>
<form method="post" action="page2.php" name="checkform" onsubmit="return submithere();">
<table cellpadding=5>
  <tr>
    <td>Name</td>
    <td><input type=text size=15 maxlength=20 class=form_style name=name tabindex=1></td>
  </tr>
  <tr>
    <td>Phone</td>
    <td><input type=text size=15 maxlength=20 class=form_style name=phone tabindex=2></td>
  </tr>
  <tr>
    <td>Email</td>
    <td><input type=text size=35 maxlength=50 class=form_style name=email tabindex=3></td>
  </tr>
  <tr>
    <td colspan=2>Details<br>
      <textarea rows=5 cols=50 class=form_style name=details></textarea>
    </td>
  </tr>
  <tr>
    <td colspan=2><input type=submit value="Submit" class=form_button_style></td>
  </tr>
</table>
</form>
 
<script language="javascript">
function submithere()
{
        if(document.checkform.name.value == "")
        {
                alert("Please enter your name.");
                return false;
        }
        if(document.checkform.phone.value == "")
        {
                alert("Please enter a phone number");
                return false;
        }
        if(document.checkform.email.value == "")
        {
                alert("Please enter a email address");
                return false;
        }
        return true;
}
</script>
 
 
 
</body>
</html>
 


Here is page2.php

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
  <head>
  <title>Page 2</title>
 <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
<body bgcolor=#ffffff>
<input type="button" name="Back" value="Modify" onclick="JavaScript&#058;self.history.back();" class="form_button_style">
 
<form method="post" action="page3.php">
<?
  // Prep the form data so we can pass it to the next page
  $name = htmlspecialchars(stripslashes($name));
  $email = htmlspecialchars(stripslashes($email));
  $phone = htmlspecialchars(stripslashes($phone));
  $details = htmlspecialchars(stripslashes($details));
?>
Please verify the following:<br>
<table cellpadding=5>
  <tr>
    <td>Name:</td>
    <td><? echo ("<b>$name</b>"); ?></td>
  </tr>
  <tr>
    <td>Phone:</td>
    <td><? echo ("<b>$phone</b>"); ?></td>
  </tr>
  <tr>
    <td>Email:</td>
    <td><? echo ("<b>$email</b>"); ?></td>
  </tr>
  <tr>
    <td colspan=2>Details:<br>
    <? echo ("<b>$details</b>"); ?>
    </td>
  </tr>
  <tr>
   <td colspan=2>Disclaimer: You are agreeing to the following</td>
  </tr>
  <tr>
    <td>
<?
echo ("<input type=hidden name=name value=\"$name\">
<input type=hidden name=phone value=\"$phone\">
<input type=hidden name=email value=\"$email\">
<input type=hidden name=details value=\"$details\">");
?>
   <input type=submit value="I Accept" class=form_button_style>
   </form> 
   </td>
   <td>
     <form type=post action="page1.php">
     <input type=submit value="I Do Not Accept" class=form_button_style>
     </form>
   </td>
  </tr>
</table>
 
<script language="javascript">
function submithere()
{
        if(document.checkform.name.value == "")
        {
                alert("Please enter your name.");
                return false;
        }
        if(document.checkform.phone.value == "")
        {
                alert("Please enter a phone number");
                return false;
        }
        if(document.checkform.email.value == "")
        {
                alert("Please enter a email address");
                return false;
        }
        return true;
}
</script>
 
 
 
</body>
</html>
 
Post Reply