Jump to content

contact form first ever try


liamloveslearning

Recommended Posts

hi guys, just tried to make my first ever contact form handcoded as opposed to downloading one online, very unsuccessful in my attempt and its bugging me, can anybody see why this isnt working? I really appreciate any help

 

html

  Book a Party<br />
              <br />
              <form id="form1" name="form1" method="post" action="bookparty.php">
                 
                 
                <p>Name <br />
                <input name="name" type="text" size="30" maxlength="40" />
                </p><p>Address<br />
                  <textarea name="address" cols="30" rows="4"></textarea>
                </p>
                <p>Phone number <br />
                <input name="phone" type="text" size="30" maxlength="40" /> 
                </p>
                <p>Email <br />
                <input name="email" type="text" size="30" maxlength="40" /> 
                </p>
                <p>Pref date of party <br />
                <input name="date" type="text" size="30" maxlength="40" /> 
                </p>
                <p>Reason for party <br />
                <textarea name="reason" cols="30" rows="4"></textarea>
                </p>
                <p>Do you require a stripper (* price on application) <br />
                Yes
                  <input name="stripper" type="radio" value="yes" />
                 No 
                 <input name="stripper" type="radio" value="no" />
                </p>
              	Is the party for a..<p>Housewarming
                <input type="checkbox" name="party" value="house"/>
                </p>
               	<p>Birthday
                  <input type="checkbox" name="party" value="birthday"/>
                </p>
              	<p>Hen night
                  <input type="checkbox" name="party" value="hennight"/>
                </p>
                 <br /><input type="submit" name="submit" id="submit" value="Send Email"/>
                </form>
                
            


                

 

 

php

 

<?php

$name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$date = $_POST['date'];
$reason = $_POST['reason'];
$stripper = $_POST['stripper'];
$party = $_POST['party'];


if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$address == "" && (!strstr($address,"@") || !strstr($address,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($name) || empty($phone) || empty($reason )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Name: $name \n
Address: $address \n
Phone: $phone \n
$email = $email \n
$date = $date \n
$reason = $reason \n
$stripper = $stripper \n
$party = $party \n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $name\r\n";


mail("liam@reloaddesign.co.uk", $name, $address, $phone);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $name ?> ( <?php echo $name ?> )
<br />

Attention: <?php echo $address ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $reason);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="contact.php"> Next Page </a>
</p> 
                
                
                
                
               

Link to comment
Share on other sites

my emails are coming through when i remove the IF email is empty statement, only not all my fields are coming through...

 

ive noticed this and changed it

 

$message = " $todayis [EST] \n

Name: $name \n

Address: $address \n

Phone: $phone \n

$email = $email \n

$date = $date \n

$reason = $reason \n

$stripper = $stripper \n

$party = $party \n

Additional Info : IP = $ip \n

Browser Info: $httpagent \n

Referral : $httpref \n

";

 

yet im only receiving the name and telephone number (address)

Link to comment
Share on other sites

You can't pass completely random information to the mail function and expect it to know what to do with it. You mail call should be of the form...

 

<?php mail('liam@reloaddesign.co.uk', 'A Subject', $message); ?>

 

Where $message is the string you created a few posts back. There is an optional 4th parameter but I recommend you ignore that untill you get everything else working.

 

I suspect that the validation your doing on your form doesn't quite work exactly as you planned also, but thats another matter.

Link to comment
Share on other sites

All of the php functions have a very specific list of parameters that they accept. These are documented in the php programming manual that is available in several formats on php.net. In order to use any php function effectively, you must make use of the documentation for that function.

 

The mail() function does not accept a generic list of the items you want to place in the message body. See this link for what the mail() function requires and actual examples -  http://www.php.net/manual/en/function.mail.php

Link to comment
Share on other sites

No we mean your passing the mail function lots of different $variables that aren't applicable to it. PFMaBiSmAd has helpfully linked to the official documentation explaining all this. But as a simple breakdown, in it's simplest format the mail function should be of this format....

 

mail  ( string $to  , string $subject  , string $message)

 

I.e. in laymans terms, you must pass it a target email address, a subject and an actually message to send.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.