Jump to content

Simple php verification


perezf

Recommended Posts

can anyone help me make it so that an is not sent unless the proper textboxes which would be the users email address and comments box is filled out

[code]
<?php
$to = "[email protected]";
$subject = "$idea";
$from_header = "From: $from";



mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/10681-simple-php-verification/
Share on other sites

[code]

<?php
$to = "[email protected]";
$subject = "$idea";
$from_header = "From: $from";

if (isset($subject && $from_header)) {

mail($to, $subject, $contents, $from_header);
    
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

}

else {
    echo 'Please go back and fill out the form';
}

?>

[/code]

gives me the error

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Parse error: parse error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /hsphere/local/home/way2fr3s/2fr3sh.com/links/email.php on line 10

[/quote]
Assuming that the form that gathered the information used method="post":

[code]<?php
$subject = trim(strip_tags($_POST['idea']));
$from = trim(strip_tags($_POST['email']));
$contents = trim(strip_tags($_POST['contents']));

if (($from!="") && ($contents!="")) {
    $to = "[email protected]";
    $from_header = "From: ". $from;
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "You forgot something";
}?>[/code]
it is gathered using post
but using the following code

[code]
<?php
    $subject = "$idea";


if (($from!="") && ($contents!="")) {
    $to = "[email protected]";
    $from_header = "From: $from";
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "Please go back and fill the form out correctly";

?>[/code]

gives me the error message

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected $ in /hsphere/local/home/way2fr3s/2fr3sh.com/links/email.php on line 17
[/quote]

the code ended up working in the end
thank you to all for your help

[code]
<?php
$subject = trim(strip_tags($_POST['idea']));
$from_header = trim(strip_tags($_POST['from']));
$contents = trim(strip_tags($_POST['contents']));

if (($from!="") && ($contents!="")) {
    $to = "[email protected]";
    $from_header = "From: ". $from;
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "You forgot something";
}?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.