Author |
Message |
cmcraft
New Member


Joined: Dec 05, 2005
Posts: 24
|
Posted:
Wed May 10, 2006 12:12 pm |
|
I am using the following code to validate a little cheesy send mail form on the front of my webpage at Only registered users can see links on this board! Get registered or login!. What I need to know is how to delay the refresh located at the bottom so that the folks can see that the mail has been sent successfully!
Code:echo" <scr ipt>
window.location=\"http://www.christophercraft.com\"
</scr ipt> ";
?>
|
Any help would be appreciated!
Yours,
Chris |
|
|
|
 |
hitwalker
Sells PC To Pay For Divorce

Joined:
Posts: 5661
|
Posted:
Wed May 10, 2006 12:56 pm |
|
this should do ...
Code:
<scr ipt>
<!--
var version = parseInt(navigator.appVersion)
if (version>=4 || window.location.replace)
setTimeout("window.location.replace('http://www.christophercraft.com')",5000);
else
window.location.href = "http://www.christophercraft.com"
// -->
</scr ipt>
|
|
|
|
|
 |
cmcraft

|
Posted:
Thu May 11, 2006 4:40 am |
|
I ran than and got this error...
Quote: | Parse error: parse error, unexpected '<' in /home/content/html/process.php on line 73 |
Here is the full code, it's a totally php file called process.php
Code:
<?php
if (!isset($_POST['submit'])) {
echo "<h1>Error</h1>\n
<p>Accessing this page directly is not allowed.</p>";
exit;
}
function cleanUp($data) {
$data = trim(strip_tags(htmlspecialchars($data)));
return $data;
}
$name = cleanUp($_POST['name']);
$email = cleanUp($_POST['email']);
$url = cleanUp($_POST['url']);
$comments = cleanUp($_POST['comments']);
if ((empty($name)) || (empty($email)) || (empty($comments))) {
echo "<h2>Input Error</h2>\n
<p><strong>Name</strong>, <strong>e-mail</strong> and <strong>comments</strong> are required fields. Please fill them in and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
if (!ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$",$email)) {
echo "<h2>Input Error</h2>\n
<p>The e-mail address \"$email\" isn't valid. Please edit it and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
$email = preg_replace("([\r\n])", "", $email);
$find = "/(content-type|bcc:|cc:)/i";
if (preg_match($find, $name) || preg_match($find, $email) || preg_match($find, $url) || preg_match($find, $comments)) {
echo "<h1>Error</h1>\n
<p>No meta/header injections, please.</p>";
exit;
}
$recipient = "";
$subject = "ChristopherCraft.com Feeedback";
$message = "Name: $name \n";
$message .= "E-mail: $email \n";
$message .= "URL: $url \n";
$message .= "Comments: $comments";
$headers = "From: ChristopherCraft dot com \r\n";
$headers .= "Reply-To: $email";
if (mail($recipient,$subject,$message,$headers)) {
echo "<p>Mail sent successfully.</p>";
} else {
echo "<p>Mail not sent this time.</p>";
}
<sc ript>
<!--
var version = parseInt(navigator.appVersion)
if (version>=4 || window.location.replace)
setTimeout("window.location.replace('http://www.christophercraft.com')",5000);
else
window.location.href = "http://www.christophercraft.com"
// -->
</scr ipt>
?>
|
Thanks for the help! You guys here are so incredible. I am sure it is something I am doing wrong. Am I correct in thinking that the code you gave me would serve well in an HTML situation?
This file is called by a simple feedback form to send me a note from my website, if that makes any difference.
Thanks!
Chris |
Last edited by cmcraft on Thu May 11, 2006 4:59 am; edited 1 time in total |
|
|
 |
hitwalker

|
Posted:
Thu May 11, 2006 4:56 am |
|
try it like this..
Code:
<?php
if (!isset($_POST['submit'])) {
echo "<h1>Error</h1>\n
<p>Accessing this page directly is not allowed.</p>";
exit;
}
function cleanUp($data) {
$data = trim(strip_tags(htmlspecialchars($data)));
return $data;
}
$name = cleanUp($_POST['name']);
$email = cleanUp($_POST['email']);
$url = cleanUp($_POST['url']);
$comments = cleanUp($_POST['comments']);
if ((empty($name)) || (empty($email)) || (empty($comments))) {
echo "<h2>Input Error</h2>\n
<p><strong>Name</strong>, <strong>e-mail</strong> and <strong>comments</strong> are required fields. Please fill them in and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
if (!ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$",$email)) {
echo "<h2>Input Error</h2>\n
<p>The e-mail address \"$email\" isn't valid. Please edit it and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
$email = preg_replace("([\r\n])", "", $email);
$find = "/(content-type|bcc:|cc:)/i";
if (preg_match($find, $name) || preg_match($find, $email) || preg_match($find, $url) || preg_match($find, $comments)) {
echo "<h1>Error</h1>\n
<p>No meta/header injections, please.</p>";
exit;
}
$recipient = "crafty184@gmail.com";
$subject = "ChristopherCraft.com Feeedback";
$message = "Name: $name \n";
$message .= "E-mail: $email \n";
$message .= "URL: $url \n";
$message .= "Comments: $comments";
$headers = "From: ChristopherCraft dot com \r\n";
$headers .= "Reply-To: $email";
if (mail($recipient,$subject,$message,$headers)) {
echo "<p>Mail sent successfully.</p>";
} else {
echo "<p>Mail not sent this time.</p>";
}
echo "<scr ipt>";
echo "<!--";
echo "var version = parseInt(navigator.appVersion)";
echo "if (version>=4 || window.location.replace)";
echo "setTimeout(\"window.location.replace('http://www.christophercraft.com')\",5000);";
echo "else";
echo "window.location.href = \"http://www.christophercraft.com\"";
echo "// -->";
echo "</scr ipt>";
?>
|
|
|
|
|
 |
cmcraft

|
Posted:
Thu May 11, 2006 5:02 am |
|
Wow. Thanks for the quick response! Should I assume that the refresh of 5000 is in seconds? |
|
|
|
 |
hitwalker

|
Posted:
Thu May 11, 2006 5:03 am |
|
well i think mili...lol
now its 5 seconds.. |
|
|
|
 |
cmcraft

|
Posted:
Thu May 11, 2006 5:36 am |
|
I ask because it doesn't redirect. It just sits on the page with the confirmation of mail sent successfully. Hmmm... |
|
|
|
 |
hitwalker

|
Posted:
Thu May 11, 2006 5:40 am |
|
try it like this...
Code:
<?php
if (!isset($_POST['submit'])) {
echo "<h1>Error</h1>\n
<p>Accessing this page directly is not allowed.</p>";
exit;
}
function cleanUp($data) {
$data = trim(strip_tags(htmlspecialchars($data)));
return $data;
}
$name = cleanUp($_POST['name']);
$email = cleanUp($_POST['email']);
$url = cleanUp($_POST['url']);
$comments = cleanUp($_POST['comments']);
if ((empty($name)) || (empty($email)) || (empty($comments))) {
echo "<h2>Input Error</h2>\n
<p><strong>Name</strong>, <strong>e-mail</strong> and <strong>comments</strong> are required fields. Please fill them in and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
if (!ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$",$email)) {
echo "<h2>Input Error</h2>\n
<p>The e-mail address \"$email\" isn't valid. Please edit it and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
$email = preg_replace("([\r\n])", "", $email);
$find = "/(content-type|bcc:|cc:)/i";
if (preg_match($find, $name) || preg_match($find, $email) || preg_match($find, $url) || preg_match($find, $comments)) {
echo "<h1>Error</h1>\n
<p>No meta/header injections, please.</p>";
exit;
}
$recipient = "";
$subject = "ChristopherCraft.com Feeedback";
$message = "Name: $name \n";
$message .= "E-mail: $email \n";
$message .= "URL: $url \n";
$message .= "Comments: $comments";
$headers = "From: ChristopherCraft dot com \r\n";
$headers .= "Reply-To: $email";
if (mail($recipient,$subject,$message,$headers)) {
echo "<p>Mail sent successfully.</p>";
} else {
echo "<p>Mail not sent this time.</p>";
}
?>
<sc ript>
<!--
var version = parseInt(navigator.appVersion)
if (version>=4 || window.location.replace)
setTimeout("window.location.replace('http://www.christophercraft.com')",5000);
else
window.location.href = "http://www.christophercraft.com"
// -->
</scr ipt>
|
If this doesnt work you could try to change it to go on submit do this ()... |
|
|
|
 |
cmcraft

|
Posted:
Thu May 11, 2006 9:17 am |
|
I hate to keep bugging you...but it returned this and I didn't know how to change it to on submit...
Quote: | Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
--------------------------------------------------------------------------------
Apache/1.3.33 Server at www.christophercraft.com Port 80 |
|
|
|
|
 |
hitwalker

|
Posted:
Thu May 11, 2006 9:21 am |
|
how you do that...lol
thats impossible..
You just uploaded it and used it as described? |
|
|
|
 |
cmcraft

|
Posted:
Thu May 11, 2006 9:25 am |
|
Absolutely. I opened process.php and copied what you gave me right in. I will try again using a new file. I will let you know. |
|
|
|
 |
cmcraft

|
Posted:
Thu May 11, 2006 9:27 am |
|
Same deal. I am using godaddy if that makes any difference. |
|
|
|
 |
gregexp
The Mouse Is Extension Of Arm

Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol
|
Posted:
Sat May 20, 2006 3:08 am |
|
now i personally have run into problems adding scripts to php so i always try to use an include funtion.
so with my thinking this is what it should look like
Code:<?php
if (!isset($_POST['submit'])) {
echo "<h1>Error</h1>\n
<p>Accessing this page directly is not allowed.</p>";
exit;
}
function cleanUp($data) {
$data = trim(strip_tags(htmlspecialchars($data)));
return $data;
}
$name = cleanUp($_POST['name']);
$email = cleanUp($_POST['email']);
$url = cleanUp($_POST['url']);
$comments = cleanUp($_POST['comments']);
if ((empty($name)) || (empty($email)) || (empty($comments))) {
echo "<h2>Input Error</h2>\n
<p><strong>Name</strong>, <strong>e-mail</strong> and <strong>comments</strong> are required fields. Please fill them in and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
if (!ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$",$email)) {
echo "<h2>Input Error</h2>\n
<p>The e-mail address \"$email\" isn't valid. Please edit it and try again:</p>";
echo "<form action=\"process.php\" method=\"post\"><p>";
echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />";
echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />";
echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />";
echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />";
echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />";
echo "</p></form>";
exit;
}
$email = preg_replace("([\r\n])", "", $email);
$find = "/(content-type|bcc:|cc:)/i";
if (preg_match($find, $name) || preg_match($find, $email) || preg_match($find, $url) || preg_match($find, $comments)) {
echo "<h1>Error</h1>\n
<p>No meta/header injections, please.</p>";
exit;
}
$recipient = "";
$subject = "ChristopherCraft.com Feeedback";
$message = "Name: $name \n";
$message .= "E-mail: $email \n";
$message .= "URL: $url \n";
$message .= "Comments: $comments";
$headers = "From: ChristopherCraft dot com \r\n";
$headers .= "Reply-To: $email";
if (mail($recipient,$subject,$message,$headers)) {
echo "<p>Mail sent successfully.</p>";
} else {
echo "<p>Mail not sent this time.</p>";
}
<scr ipt language=\"javascript\" type=\"text/javascript\" src=\"includes/delayscript.js\"></scr ipt>
?>
|
and throw this in a text file
Code:
<!--
var version = parseInt(navigator.appVersion)
if (version>=4 || window.location.replace)
setTimeout("window.location.replace('http://www.christophercraft.com')",5000);
else
window.location.href = "http://www.christophercraft.com"
// -->
|
now because the include is wrapped in the words script..it doesnt need the script tags
but all i did was add this code right above the ?>
Code:
<scr ipt language=\"javascript\" type=\"text/javascript\" src=\"includes/delayscript.js\"></scr ipt>
|
remember that in order to post all this..we had to space the <scr ipt> tags
Also the code block broke some of the code and made it a 2 liner...u MUST make sure its not brokin when u copy and paste it...use the original and just through that code in it would be ur best bet. |
|
|
 |
 |
djmaze
Subject Matter Expert

Joined: May 15, 2004
Posts: 727
Location: http://tinyurl.com/5z8dmv
|
Posted:
Sat May 20, 2006 9:41 pm |
|
Ehm this is the PHP forum and NOT javascript forum.
So why do i see crappy JavaScript codes to try an delay while there exists an refresh header?
Code:<?php
header('Refresh: 5; url=http://www.christophercraft.com/');
|
|
_________________ $ mount /dev/spoon /eat/fun auto,overclock 0 1
ERROR: there is no spoon
http://claimedavatar.net/ |
|
|
 |
gregexp

|
Posted:
Tue May 23, 2006 4:40 pm |
|
nice to know...thanx  |
|
|
|
 |
|