echo '<script> alert("THANK YOU FOR SUBSCRIBING TO THE NEWSLETTER") </script>';
如果我希望在正确提交表单的情况下显示此警报,我应该在哪里放置此警报?
<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Add this Email Address to Mailing List';
// Your email address. This is where the form information will be sent.
$emailadd = 'test398ty32@gmail.com';
// Where to redirect after form is processed.
$url = 'http://10.0.1.1/~macpro';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo '<script> alert("PLEASE ENTER A VALID EMAIL ADDRESS") </script>';$url; }
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
谢谢