PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
well using <a href=\'contact.php\'> works but the link doesn't work, even though that is the correct file name. Ideally what I am wanting is something that will hi-light the required fields that haven't been completed. Currently with this script all fields are required.
<?php
$subject = 'There has been a disturbance in the force!'; // Subject of email sent to you.
$emailadd = 'webguync@gmail.com'; // Your email address. This is where the form information will be sent.
$url = 'Thankyou.php'; // Where to redirect after form is processed.
$req = '1'; // 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.
// --------------------------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 "$key has not been completed. Please <a href=\'Contact.php\'>Try again!</a>";die;}
}
$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.'">';
?>
$example = mysql_query("SELECT something FROM tablename WHERE column='whatever'")
or die(mysql_error());
when working with the die's becasue it shoots out some kind of error. Try that format instead to see if it helps, but since I don't know what the h-e-double-hockeysticks I'm doing, one of the gurus could probably suggest something better.
<?php
$subject = 'There has been a disturbance in the force!'; // Subject of email sent to you.
$emailadd = 'webguync@gmail.com'; // Your email address. This is where the form information will be sent.
$url = 'Thankyou.php'; // Where to redirect after form is processed.
$req = '1'; // 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.
// --------------------------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 "$key has not been completed. Please <a href='Contact.php'>Try again!</a>";
die;
}
}
$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.'">';
?>
You're putting slashes where they are not needed, and thus turning the URL literally, into \contact.php\.