Hi, I’ve been updating a clients site that already had a registration page with php init. I’ve looked at the code and cant see why it’s not working there are no errors displayed but on submit the form hangs on a white page, any help would be much appreciated, my php knowledge is not great.
Please find my code below:
[php]
<html>
<head>
<title>Form Error</title>
</head>
<body>
<form action="register.php" method="post" id="error_form">
<input type="hidden" name="parents_name" value="<? echo $ParentsName ?>" />
<input type="hidden" name="firstname" value="<? echo $firstname ?>" />
<input type="hidden" name="surname" value="<? echo $surname ?>" />
<input type="hidden" name="address1" value="<? echo $address1 ?>" />
<input type="hidden" name="address2" value="<? echo $address2 ?>" />
<input type="hidden" name="city" value="<? echo $city ?>" />
<input type="hidden" name="county" value="<? echo $county ?>" />
<input type="hidden" name="postcode" value="<? echo $postcode ?>" />
<input type="hidden" name="email_address" value="<? echo $email_address ?>" />
<input type="hidden" name="telephone" value="<? echo $telephone ?>" />
<input type="hidden" name="mobile" value="<? echo $mobile ?>" />
<input type="hidden" name="sex" value="<? echo $sex ?>" />
<input type="hidden" name="dob_day" value="<? echo $dob_day ?>" />
<input type="hidden" name="dob_month" value="<? echo $dob_month ?>" />
<input type="hidden" name="dob_year" value="<? echo $dob_year ?>" />
<input type="hidden" name="height" value="<? echo $height ?>" />
<input type="hidden" name="hairlength" value="<? echo $hairlength ?>" />
<input type="hidden" name="haircolour" value="<? echo $haircolour ?>" />
<input type="hidden" name="eyecolour" value="<? echo $eyecolour ?>" />
<input type="hidden" name="ethnicorigin" value="<? echo $ethnicorigin ?>" />
<input type="hidden" name="shoesize" value="<? echo $shoesize ?>" />
<input type="hidden" name="loginname" value="<? echo $loginname ?>" />
<input type="hidden" name="passwd" value="<? echo $passwd ?>" />
<input type="hidden" name="repeat_passwd" value="<? echo $repeat_passwd ?>" />
<? echo $message ?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('error_form').submit();
//-->
</script>
</body>
</html>
<?
} else {
// INSERT THE APPLICATION INTO THE DATABASE FOR SAFE KEEPING AND EASY UPDATE OF NEW MEMBER
if (file_exists("images/uploads/$folder/$firstname-$surname-1.jpg")) {
$image_1 = "images/uploads/$folder/$firstname-$surname-1.jpg";
} else {
$image_1 = "";
}
if (file_exists("images/uploads/$folder/$firstname-$surname-2.jpg")) {
$image_2 = "images/uploads/$folder/$firstname-$surname-2.jpg";
} else {
$image_2 = "";
}
if (file_exists("images/uploads/$folder/$firstname-$surname-3.jpg")) {
$image_3 = "images/uploads/$folder/$firstname-$surname-3.jpg";
} else {
$image_3 = "";
}
if (file_exists("images/uploads/$folder/$firstname-$surname-4.jpg")) {
$image_4 = "images/uploads/$folder/$firstname-$surname-4.jpg";
} else {
$image_4 = "";
}
$insert = mysql_query("INSERT INTO registrations (page_url, parents_name, firstname, surname, address1, address2, city, county, postcode, email_address, telephone, mobile, sex, date_of_birth, height, hairlength, haircolour, eyecolour, ethnic_origin, shoesize, image_1, image_2, image_3, image_4, username, passwd) VALUES ('$page_url', '$parents_name', '$firstname', '$surname', '$address1', '$address2', '$city', '$county', '$postcode', '$email_address', '$telephone', '$mobile', '$sex', '$date_of_birth', '$height', '$hairlength', '$haircolour', '$eyecolour', '$ethnicorigin', '$shoesize', '$image_1', '$image_2', '$image_3', '$image_4', '$loginname', '$passwd')") or die (mysql_error());
$id = mysql_insert_id();
$skills = $_POST["Skills"];
foreach($skills as $value) {
$skills_insert_query = mysql_query("INSERT INTO registration_skills (registrant_id, skill) VALUES ('$id', '$value')") or die (mysql_error());
}
// SEND THE APPLICANTS DETAILS TO STEVE AND KAREN
$to="myemail@domain, [email protected]";
$subject="New Kids Management Application";
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['ParentsName'])."<".stripslashes($_POST['EmailAddress']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// now we'll build the message headers
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
// here, we'll start the message body.
// this is the text that will be displayed
// in the e-mail
$message =
"You have received a new appilcation for representation from the Kids Management website:\r\n\r\n".
"Parent Name: $parents_name\r\n\r\n".
"Childs Name: $firstname $surname\r\n\r\n".
"Address $address1\r\n".
"$address2\r\n".
"$city\r\n".
"$county\r\n".
"$postcode\r\n\r\n".
"Email Address: $email_address\r\n\r\n".
"Contact Telephone: $telephone\r\n\r\n".
"Mobile Number: $mobile\r\n\r\n".
"Childs Sex: $sex\r\n\r\n".
"Date of Birth: $date_of_birth\r\n\r\n".
"Height: $height\r\n\r\n".
"Hair Length: $hairlength\r\n\r\n".
"Hair Colour: $haircolour\r\n\r\n".
"Eye Colour: $eyecolour\r\n\r\n".
"Ethnic Origin: $ethnicorigin\r\n\r\n".
"Shoe Size: $shoesize\r\n\r\n".
"Website Login Name: $loginname\r\n\r\n";
// next, we'll build the invisible portion of the message body
// note that we insert two dashes in front of the MIME boundary
// when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// now we'll process our uploaded files
for($i = 1; $i <= 4; $i++){
// if the upload succeded, the file will exist
if (file_exists("images/uploads/$folder/$firstname-$surname-$i.jpg")) {
$size = getimagesize("images/uploads/$folder/$firstname-$surname-$i.jpg");
$tmp_name = "images/uploads/$folder/$firstname-$surname-$i.jpg";
$name = "$firstname-$surname-$i.jpg";
$type = $size['mime'];
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content.
// NOTE: we don't set another boundary to indicate that the end of the
// file has been reached here. we only want one boundary between each file
// we'll add the final one after the loop finishes.
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}
// here's our closing mime boundary that indicates the last of the message
$message.="--{$mime_boundary}--\n";
// now we just send the message
mail($to, $subject, $message, $headers);
$url = 'http://www.mydomain.co.uk/example-page.php';
}
}
?>
[/php]
I will upoload the register page next…