For some reason, when I had these set up on a free hosting server which I was testing them out, they worked perfectly fine.
But, i registered w/ GoDaddy and when i copy and pasted the forms which are identical, except, I changed the links and my email, it won’t send at all.
I hope someone could help me with this? I posted on this forum before about the same contact form and attachment form, but, they worked on the free hosting site I was testing on. I’m really confused about what is going on with this. Thanks a lot in advance.
- Contact form
When I fill it out, it says “please fill out the form” and it doesn’t send at all. When I took away the php code which will say “please fill out the form”, it DID send, however, it didn’t say “Thank you NAME, you will be contacted at EMAIL”. Instead, it said, “Thank you, you will be contacted at,”.
Here is my PHP code:
<?php
if(!empty($_POST)) {
if (!($name || $email || $message)) {
echo '<div class="error">Please complete the form.</div><br />';
} else {
if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) {
echo '<div class="error">Please enter a valid e-mail.<br /></div>';
} else {
if (empty($_POST['name']) ) {
echo '<div class="error">Please enter your name.<br /></div>';
} else {
if (empty($_POST['message']) ) {
echo '<div class="error">Please enter your message.<br /></div>';
} else {
echo '<div class="thankyou">Thank you, '.$name.'! You will be contacted back at '.$email.'.</div>';
$to = "support@MYDOMAIN.com";
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$body = "From:
$name
Email:
$email
Message:
$message";
$finished = mail($to,$email,$body,$headers);
}
}
}
}
}
?>
Here is the form that I use:
<form method="POST" action="<?php echo $PHP_SELF;?>" id="contactform">
Name<div class="boldrequired">(required)</div><br />
<input type="text" name="name" size="19"><br>
<br>
E-Mail <div class="boldrequired">(required)</div><br />
<input type="text" name="email" size="19"><br>
<br>
Message<div class="boldrequired">(required)</div><br />
<textarea rows="10" name="message" cols="40" wrap="hard"></textarea>
<br>
<br>
<input type="submit" value="Submit" name="submit">
</form>
- This is a form that will be able to send a picture attachment. This has worked perfectly on the free hosting site, the code is exactly the same but i changed the e-mail. Now, when I try to send anything, it wont even give an error message, nothing at all.
<?php
// Include all the output functions
require_once('http://www.MYDOMAIN.com/submitphoto.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
</style>
</head>
<body>
<div id="uploadform">
<?php
// contact form
if (isset($_POST['submitted']) && ('true' == $_POST['submitted'])) {
// checks if the form is submitted and then processes it
process_form();
} else {
// else prints the form
print_form();
}
?>
</div>
</body>
</html>
**The actual form is in this code below.
**
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PaniDolls.com</title>
<link href="http://www.MYDOMAIN.com/css/submitphotocss.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.error {font-weight: bold; font-size: 12px; background-color: #74bce3; width: 180px;}
.thankyou {font-weight: bold; font-size:12px; background-color: #74bce3; width: auto;}
</style>
</head>
<body>
<span style="font-size: 18px; color: #f47592; font-weight: bold;">Submit My Photo!</span><br />
<img src="http://MYDOMAIN/img/horizdivider.png" alt="divider" />
<form method="POST" action="<?php echo $PHP_SELF;?>" id="attach" enctype="multipart/form-data">
<div class="fieldtitles">Name <span style="font-weight:bold;">(required)</span>:
<input type="text" name="name" size="19"><br>
<br></div>
<div class="fieldtitles">E-Mail <span style="font-weight:bold;">(required)</span>:
<input type="text" name="email" size="19"><br>
<br></div>
<div class="fieldtitles">City/State/Country:
<input type="text" name="location" size="19"><br>
</div>
<br>
<div class="fieldtitles">Upload Photo <span style="font-weight:bold;">(required)</span><br />
<span style="font-size: 10px; font-weight: bold; color:#000000;">File size: Less than 400K.<br />
File type: .jpg ONLY.</span><br />
</div>
<input name="attachment" id="attachment" type="file" tabindex="7"><br />
<br />
<div class="title"> Please read the text below before hitting the "SUBMIT" button. </div>
<br />
<br />
<input type="submit" value="Submit My Photo!" name="submit">
<input type="hidden" name="submitted" value="true" />
</form>
<?php
// prints form
function print_form(){
?>
<br />
<?php
}
// enquiry form validation
function process_form() {
// Read POST request params into global vars
// FILL IN YOUR EMAIL
$to = "support@mydomain.com";
$name = trim($_POST['name']);
$location = trim($_POST['location']);
$email = trim($_POST['email']);
// Allowed file types. add file extensions WITHOUT the dot.
$allowtypes=array("jpg", "jpeg", "JPG", "JPEG", "Jpeg", "Jpg");
// Maximum file size for attachments in KB NOT Bytes for simplicity. MAKE SURE your php.ini can handel it,
// post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB, 1024kb = 1MB, 512kb = 1/2MB etc..
$max_file_size="800";
// Thank you message
$thanksmessage="Thank you.";
$errors = array(); //Initialize error array
//checks for a name
if (empty($_POST['name']) ) {
$errors[]='Please enter your name.';
}
//checks for an email
if (empty($_POST['email']) ) {
$errors[]='Please enter your e-mail.';
} else {
if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) {
$errors[]='Please enter a valid email address';
// if eregi
} // if empty email
}
//checks attachment file
// checks that we have a file
if((!empty($_FILES["attachment"])) && ($_FILES['attachment']['error'] == 0)) {
// basename -- Returns filename component of path
$filename = basename($_FILES['attachment']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
$filesize=$_FILES['attachment']['size'];
$max_bytes=$max_file_size*800;
//Check if the file type uploaded is a valid file type.
if (!in_array($ext, $allowtypes)) {
$errors[]="You have uploaded a file with the wrong extention: <strong>".$filename."</strong> Please upload a .jpeg file.";
// check the size of each file
} elseif($filesize > $max_bytes) {
$errors[]= "The filename you've uploaded: <strong>".$filename."</strong>, is too big. Max file size is ".$max_file_size."kb.";
}
} // if !empty FILES
if (empty($errors)) { //If everything is OK
// send an email
// Obtain file upload vars
$fileatt = $_FILES['attachment']['tmp_name'];
$fileatt_type = $_FILES['attachment']['type'];
$fileatt_name = $_FILES['attachment']['name'];
// Headers
$headers = "From: $email";
// create a boundary string. It must be unique
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "
MIME-Version: 1.0
" .
"Content-Type: multipart/mixed;
" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message ="This is a multi-part message in MIME format.
";
$message.="--{$mime_boundary}
";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"
";
$message.="Content-Transfer-Encoding: 7bit
";
$message.="From: ".$name."
";
$message.="From: ".$email."
";
$message.="Location: ".$location."
";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}
" .
"Content-Type: {$fileatt_type};
" .
" name=\"{$fileatt_name}\"
" .
//"Content-Disposition: attachment;
" .
//" filename=\"{$fileatt_name}\"
" .
"Content-Transfer-Encoding: base64
" .
$data . "
" .
"--{$mime_boundary}--
";
}
// Send the completed message
if(!mail($to,$subject,$message,$headers)) {
echo "There has been a problem and your information was NOT processed. We're VERY SORRY for this inconvenience. Please try again - if this problem persists, please contact support@panidolls.com Thank you for your patience and cooperation!
";
} else {
echo '<div class="thankyou">Thank you for your submission, '.$name.'! We are happy to have you participate in the customer gallery! Please check back to see your picture posted. If you have any questions please do not hesitate to contact us through our contact form.</div>';
print_form();
} // end of if !mail
} else { //report the errors
echo '<div class="error">There has been an error:<br /></div>';
foreach ($errors as $msg) { //prints each error
echo " - $msg<br />
";
} // end of foreach
print_form();
} //end of if(empty($errors))
} // end of process_form()
?>
Thanks a lot again,