Forum Moderators: coopster

Message Too Old, No Replies

PHP not passing variables between pages

         

Horgy

12:02 am on Feb 26, 2006 (gmt 0)



Hi guys,

I'm quite new to PHP, i've setup a simple two page site to verify then post some data into MySQL.

The first site collects the information, verifies it, then sends it on to the second, which puts it in the database - but the first page doesnt appear to be sending the variables to the second. I've attached the code below, any ideas why this is?

--------PAGE 1 (origrecruitment.php)------------

<?php

$errgo = 0;

if ( $_POST['submit'] ) {

$valid = 1;
$errgo = 1;

}

$err1 = '<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
<tr>
<td width="9%">
<img border="0" src="cross.gif" width="50" height="50"></td>
<td width="91%"><b><font face="Tahoma">Sorry!</font></b><p>
<font face="Tahoma">There appears to be a problem. Please correct the
following errors and resubmit your application.</font></td>
</tr>
<tr>
<td width="9%">&nbsp;</td>
<td width="91%">
<ul>';

$err2 = ' </ul>
</td>
</tr>
</table>';

$Pass=$_POST['Pass'];
$FName=$_POST['FName'];
$SName=$_POST['SName'];
$Email=$_POST['Email'];
$EmailC=$_POST['EmailC'];
$Address=$_POST['Address'];
$PCode=$_POST['PCode'];
$Country=$_POST['Country'];
$OFID=$_POST['OFID'];
$Base=$_POST['Base'];
$PHr=$_POST['PHr'];
$PHrContact=$_POST['PHrContact'];
$DOB=$_POST['DOB'];

if ( empty($FName) ) {
$valid = 0;
$FName_error = '<li><font face="Tahoma">Please ensure you have filled in your first name</font></li>';
}

if ( empty($SName) ) {
$valid = 0;
$SName_error = '<li><font face="Tahoma">Please ensure you have filled in your Surname</font></li>';
}

if ( empty($Email) ) {
$valid = 0;
$Email_error = '<li><font face="Tahoma">Please ensure you have filled in your E-Mail Correctly</font></li>';
}

if ( empty($EmailC) ) {
$valid = 0;
$EmailC_error = '<li><font face="Tahoma">Please ensure you have filled in your E-Mail Correctly</font></li>';
}

if ( empty($Pass) ) {
$valid = 0;
$Pass_error = '<li><font face="Tahoma">Please ensure you have filled in a Password</font></li>';
}

if ( empty($DOB) ) {
$valid = 0;
$DOB_error = '<li><font face="Tahoma">Please ensure you have filled in your Date of Birth in the format

DD/MM/YYYY</font></li>';
}

if ( $valid == 1 ) {

$messageARS = 'Someone has submitted an online application for employment.' . "\n\n";
$messageARS .= 'First Name: ' . $FName . "\n";
$messageARS .= 'Surname: ' . $SName . "\n";
$messageARS .= 'Email: ' . $Email . "\n";
$messageARS .= 'DOB: ' . $DOB . "\n";
$messageARS .= 'Base: ' . $Base . "\n\n";
$messageARS .= 'Address: ' . $Address . "\n";
$messageARS .= 'Post Code: ' . $PCode . "\n";
$messageARS .= 'Country Code: ' . $Country . "\n\n";
$messageARS .= 'VATSIM/IVAO ID: ' . $OFID . "\n";
$messageARS .= 'Hours To Transfer - If Any: ' . $PHr . "\n";
$messageARS .= 'Hours - Verification via: ' . $PHrContact . "\n";

$message = 'Dear ' . $FName . "\n\n";
$message .= 'Thank you for your recent application to us. Your application has been recieved and is being considered.

Please be patient, applications take 72 hours or more to process. Once this process is complete, you will be notified via E-

mail, and your membership will be activated. Ensure you know your password - you will be issued a username when the

application process has been completed.' . "\n\n";
$message .= 'If you have asked us to transfer your hours to us this process can be lengthy, depending on

the ease of verifying the hours with the person or website named in your application. Should we be unable to verify these

hours, they may not be credited.' . "\n\n";
$message .= 'In the meantime, i\'d like to provisionally welcome you aboard - we hope to see you in the skies very soon!' .

"\n\n";
$message .= 'Best Regards' . "\n\n";
$message .= 'James' . "\n\n";
$message .= 'Manager' . "\n";

$subjectARS = 'Recruitment E-Mail';
$subject = 'AutoResponse from Recruitment';

$sendTo = 'address@addres.com';

$header = 'From: Recruitment <fghfh@fhgfh.com>' . "\r\n";

$headerARS = 'To: Recruitment Queue <fhgfh@fghfhe.com>' . "\r\n";
$headerARS .= 'From: ARS <fhgfh@fhgfh.com>' . "\r\n";

//mail($Email, $subject, $message, $header);

//mail($sendTo, $subjectARS, $messageARS, $headerARS);

header ("Location: dorecruit.php");

}

?>

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Recruitment</title>
<base target="_self">
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body bgproperties="fixed" background="webback.jpg">

XXGARBAGEXX

<?php

if ( $errgo == 1 ) {
if ( $valid == 0 ) {
echo $err1;
echo $FName_error;
echo $SName_error;
echo $Email_error;
echo $Pass_error;
echo $DOB_error;
echo $err2;
}
}

?>

<p><font face="Tahoma"><font color="#FF0000">*</font> Denotes required field.</font></p>

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%"

id="AutoNumber1">
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<tr>
<td width="50%"><font face="Tahoma"><font color="#FF0000">*</font> First
Name:</td>
<td width="50%"><input type="text" name="FName" size="20" value="<?php echo $FName;?>">
</td>
</tr>
<tr>
<td width="50%"><font face="Tahoma"><font color="#FF0000">*</font> Surname:</font></td>
<td width="50%">
<input type="text" name="SName" size="20" value="<?php echo $SName;?>"></td>
</tr>
<tr>
<td width="50%"><font face="Tahoma"><font color="#FF0000">*</font> E-Mail
Address:</font></td>
<td width="50%"><input type="text" name="Email" size="20" value="<?php echo $Email;?>"></td>
</tr>
<tr>
<td width="50%"><font face="Tahoma"><font color="#FF0000">*</font> Confirm
E-Mail Address:</td>
<td width="50%"><input type="text" name="EmailC" size="20" value="<?php echo $EmailC;?>"></td>
</tr>
<tr>
<td width="50%"><font face="Tahoma"><font color="#FF0000">*</font> Desired
Password:</td>
<td width="50%"><input type="Password" name="Pass" size="20" value="<?php echo $Pass;?>"></td>
</tr>
<tr>
<td width="50%"><font face="Tahoma"><font color="#FF0000">*</font> Date of
Birth:</td>
<td width="50%"><input type="text" name="DOB" size="20" value="<?php echo $DOB;?>"></td>
</tr>
<tr>
<td width="50%">&nbsp;</td>
<td width="50%">&nbsp;</td>
</tr>
<tr>
<td width="50%"><font face="Tahoma">Address:</font></td>
<td width="50%"><textarea rows="4" name="Address" cols="20"><?php echo $Address;?></textarea></td>
</tr>
<tr>
<td width="50%"><font face="Tahoma">PostCode:</font></td>
<td width="50%"><input type="text" name="PCode" size="20" value="<?php echo $PCode;?>"></td>
</tr>
<tr>
<td width="50%"><font face="Tahoma">Country:</font></td>
<td width="50%">
<select size="1" name="Country">
<option selected VALUE=GBR>United Kingdom</option>
<option value=ZWE>Zimbabwe</option>
</select></td>
</tr>
<tr>
<td width="50%">&nbsp;</td>
<td width="50%">&nbsp;</td>
</tr>
<tr>
<td width="50%"><font face="Tahoma"><font color="#FF0000">* </font>Desired
Base:</font></td>
<td width="50%">
<select size="1" name="Base">
<option value="MAN">Manchester (MAN)</option>
</select>
</td>
</tr>
<tr>
<td width="50%"><font face="Tahoma">VATSIM ID:</font></td>
<td width="50%"><input type="text" name="OFID" size="20" value="<?php echo $OFID;?>"></td>
</tr>
<tr>
<td width="50%">&nbsp;</td>
<td width="50%">&nbsp;</td>
</tr>
<tr>
<td width="50%"><font face="Tahoma">If you wish to transfer existing hours,
fill in the details below:<br>
&nbsp;</font></td>
<td width="50%">&nbsp;</td>
</tr>
<tr>
<td width="50%"><font face="Tahoma">Hours You Wish to Transfer:</font></td>
<td width="50%"><input type="text" name="PHr" size="20" value="<?php echo $PHr;?>"></td>
</tr>
<tr>
<td width="50%"><font face="Tahoma">Person / Website Verification Contact:</font></td>
<td width="50%"><input type="text" name="PHrContact" size="20" value="<?php echo $PHrContact;?>"></td>
</tr>
</table>

<p align="center"><font face="Arial">
<input type="submit" value="Submit" name="submit" style="font-family: Tahoma"></font>&nbsp;
<input type="reset" value="Reset" name="reset" style="font-family: Tahoma"></p>
</form>

</body>

</html>

---------------Page 2 (dorecruit.php)--------

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>DoRecruit</title>
<base target="_self">
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body bgproperties="fixed" background="webback.jpg">

<?
$username="sfddsf";
$password="sfddsfds";

$Pass=$_POST['Pass'];
$FName=$_POST['FName'];
$SName=$_POST['SName'];
$Email=$_POST['Email'];
$Address=$_POST['Address'];
$PCode=$_POST['PCode'];
$Country=$_POST['Country'];
$OFID=$_POST['OFID'];
$Base=$_POST['Base'];
$PHr=$_POST['PHr'];
$PHrContact=$_POST['PHrContact'];
$DOB=$_POST['DOB'];

$Passcrypt=md5($Pass);

echo $Passcrypt;

mysql_connect('lsnfsldnfsldnf',$username,$password);
mysql_select_db('dsfsfd') or die(mysql_error());

$query = "INSERT INTO pilots VALUES ('','$Passcrypt','$FName','$SName','$Email','$Address','$PCode','$Country','$OFID','$Base','$PHr','$PHrContact','$DOB','N')";
mysql_query($query) or die(mysql_error());

mysql_close();

?>
<p align="center"><b><font face="Tahoma" size="4">Recruitment</font></b></p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
<td width="9%"><img border="0" src="tick.gif" width="50" height="50"></td>
<td width="91%"><font face="Tahoma">Thank you for your application.</font></td>
</tr>
</table>
<p><font face="Tahoma">Once it has been approved you will be issued with a
username and password for &quot;MyCrewRoom&quot; - where you can access documents, downloads, and SOP's.</font></p>
<p><font face="Tahoma">Please be patient, we aim to process applications within
72 hours.</font></p>

</body>

</html>

------END-------

I've removed stuff like username / password (obviously) I now they are correct. I don't know if i need these lines (e.g. $DOB=$_POST['DOB'];) in both, could somwone clarify that?

And for what its worth, I know the stuff should be going in ok, beacuse in the table I get the passcrypt equivalent of whitespace, and the "N" from the last dummy field.

Any help much appreciated.

Horgy

khaki monster

4:13 am on Feb 27, 2006 (gmt 0)

10+ Year Member



check your PHP codes carefully...
<?php echo $_SERVER['PHP_SELF'];?> NOT <?php echo $_SERVER['PHP_SELF'];?>
<?php echo $FName;?> NOT <?php echo $FName;?>
and the rest of the codes...
...
...

khaki monster

4:50 am on Feb 27, 2006 (gmt 0)

10+ Year Member



you invoke $_SERVER['PHP_SELF']; which is actually('Only') execute the current script.
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
try change with this one <form method="post" action="dorecruit.php">

then after the query... you may use header() function to redirect you to form('reqruitment') page.