james_d_kelly
11-28-2005, 04:53 PM
Hi all,
Ive got a bit of a problem when writing my own php script, when my browser and editor are loading/running the script a window pops up saying "do i want to download the file: contact.php". Other php scripts on websites work but any i write allways try to get downloaded or opened in a picture/photo editor (as a picture .php file). Whats going on, how can i run my scripts without uploaing them to a server! :confused:
It would also be very helpful if someone could cheack over my script as its not working as i cant script very well. :o
this is my script:
<?php
if(isset($_POST['Submit'])){
// get posted data into local variables
$EmailTo = "james_d_kelly@yahoo.co.uk";
$EmailFrom = Design Source Contact Form;
$Subject = "Design Source Mail";
$G1 = Trim(stripslashes($_POST['G1']));
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
,'Name','Email','Message']));
// prepare email body text
$Body = "";
$Body .= "Message type: ";
$Body .= $G1;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$CheckEmail = trim($_POST['Email']);
if (eregi($CheckEmail)){
$success = @mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
}
}
echo <<< HEAD
<html>
<head>
</head>
<body>
HEAD;
if($success){
echo "<script language=\"javascript\">\n";
echo "<!--\n";
echo "alert(\"Thank you for contacting Design Source. If you require a reply, we will get back to you shortly.\");";
echo "history.back()";
echo "\n\/\/-->";
echo "</script>";
}elseif(isset($_POST['B1']) && $success == FALSE){
echo "<script language=\"javascript\">\n";
echo "<!--\n";
echo "alert(\"There was an error, please try again.\");";
echo "history.back()";
echo "\n\/\/-->";
echo "</script>";
}
if(!isset($_POST['B1']) | $success == FALSE){
echo <<< FORM
<form method="POST" action="http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}">
<input type="radio" value="General Enquiry" name="R1">General Enquiry<br>
<input type="radio" name="R1" value="Comment/Suggestion">Comment / Suggestion<br>
<input type="radio" name="R1" value="Complaint">Complaint<br>
<input type="text" name="Name" size="25" value="Your Name..."><br>
<input type="text" name="email" size="25" value="Your Email Address..."><br>
<textarea rows="4" name="message" cols="30">Your message here...</textarea><br>
<input type="submit" value="Send" name="Submit"><br><br>
</form>
FORM;
}
echo <<< FOOT
</body>
</html>
FOOT;
?>
Thanks for any help
Ive got a bit of a problem when writing my own php script, when my browser and editor are loading/running the script a window pops up saying "do i want to download the file: contact.php". Other php scripts on websites work but any i write allways try to get downloaded or opened in a picture/photo editor (as a picture .php file). Whats going on, how can i run my scripts without uploaing them to a server! :confused:
It would also be very helpful if someone could cheack over my script as its not working as i cant script very well. :o
this is my script:
<?php
if(isset($_POST['Submit'])){
// get posted data into local variables
$EmailTo = "james_d_kelly@yahoo.co.uk";
$EmailFrom = Design Source Contact Form;
$Subject = "Design Source Mail";
$G1 = Trim(stripslashes($_POST['G1']));
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
,'Name','Email','Message']));
// prepare email body text
$Body = "";
$Body .= "Message type: ";
$Body .= $G1;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$CheckEmail = trim($_POST['Email']);
if (eregi($CheckEmail)){
$success = @mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
}
}
echo <<< HEAD
<html>
<head>
</head>
<body>
HEAD;
if($success){
echo "<script language=\"javascript\">\n";
echo "<!--\n";
echo "alert(\"Thank you for contacting Design Source. If you require a reply, we will get back to you shortly.\");";
echo "history.back()";
echo "\n\/\/-->";
echo "</script>";
}elseif(isset($_POST['B1']) && $success == FALSE){
echo "<script language=\"javascript\">\n";
echo "<!--\n";
echo "alert(\"There was an error, please try again.\");";
echo "history.back()";
echo "\n\/\/-->";
echo "</script>";
}
if(!isset($_POST['B1']) | $success == FALSE){
echo <<< FORM
<form method="POST" action="http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}">
<input type="radio" value="General Enquiry" name="R1">General Enquiry<br>
<input type="radio" name="R1" value="Comment/Suggestion">Comment / Suggestion<br>
<input type="radio" name="R1" value="Complaint">Complaint<br>
<input type="text" name="Name" size="25" value="Your Name..."><br>
<input type="text" name="email" size="25" value="Your Email Address..."><br>
<textarea rows="4" name="message" cols="30">Your message here...</textarea><br>
<input type="submit" value="Send" name="Submit"><br><br>
</form>
FORM;
}
echo <<< FOOT
</body>
</html>
FOOT;
?>
Thanks for any help