![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Dec 2008
Location: Minnesota
Posts: 113
OS: Vista Ultimate 64 bit SP1. Linux Ubuntu, XP Pro
|
PHP Email form problem
Ok. I am stuck and I feel damn stupid for this.
I am making an email send form, that will contain several sections. Users email addy, phone number, question and several other options. I have developed this PHP form,but unsure exactly where to put my email address for it to send all the info to my inbox. I have been working 4am shifts this week and tired, I just can not see where I am going wrong. Still learning PHP. I do currently have the form in place using XHTML, but wish to program with PHP mainly from now on. Plus I got to learn all this inside out for college, when I start in September. Here is my PHP code. Code:
<?php
/*variable names for xhtml input*/
$name = $HTTP_POST_VARS ['name'];
$email = $HTTP_POST_VARS['email'];
$phone = $HTTP_POST-VARS['phone'];
$contact_choice = $HTTP_POST_VARS ['contact'];
$quick_form = $HTTP_POST_VARS ['quickform'];
$time = $HTTP_POST_VARS ['time'];
$message = $HTTP_POST_VARS['message'];
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email='example@example.com')) **
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($message == "") **
echo "<h4>You have not entered a message </h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif (mail($name,$email,$phone,$contact_choice,$quick_form,$time,$message )) **
echo "<h4>Thank you for contacting us, you shall receive a reply very soon.</h4>";
} else **
echo "<h4>Can't send email to $email</h4>";
}
?>
Code:
<$php
<form action="mail.php" method="POST">
<strong>Name:</strong> <input type="text" size="10" maxlength="40" name="name" /> <br />
<br />
<strong>Email: </strong> <input type="text" size="10" maxlength="45" name="email" /><br />
<br />
<strong>Phone:</strong> <input type="text" size="10" maxlength="45" name="phone" /><br />
<br />
<br />
<center><cite><u><strong>How would you like us to contact you?</strong></u></cite></center>
<br />
<input type="checkbox" name="email" value="email" /> Email
<input type="checkbox" name="phone" value="phone" /> Phone
<br />
<br />
<center><cite><u><strong>Select an option to help process your email quicker</strong></u></cite></center>
<br />
<input type="checkbox" name="quickform" value="t-shirts" />T-shirts
<input type="checkbox" name="quickform" value="shorts" />Shorts
<input type="checkbox" name="quickform" value="tank tops" />Tank tops
<input type="checkbox" name="quickform" value="General Query" />General Query
<br />
<br />
Best time to contact you? :
<select name="time" />
<option>Select Time</option>
<option>9am - 12 noon</option>
<option>Noon - 6pm</option>
<option>6pm - 9pm</option>
</select>
<br />
<br />
<textarea rows="10" cols="80" wrap="physical" name="message" />
Enter text here:
</textarea>
<br />
<br />
<input type="submit" value="Send" />
</form>
It is near bed time,. back up at 3am for work. The 3 days off, to get this sorted and get lots of other work completed.
|
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Design Team Member
|
Re: PHP Email form problem
You can probably simplify the email address validation with PHP5's filter_var:
PHP Code:
PHP Code:
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#3 (permalink) |
|
Design Team Member
|
Re: PHP Email form problem
Oh by the way...
There's no such thing as feeling stupid for asking for help when you're stuck! :) TRUST me, even if you're a pro you WILL make mistakes. There will be times where your code looks perfect as you've combed over it 10-15 times and it is just not working. Here's the key: you've messed it up. 99% of the time whenever something isn't working and I'm stuck, it really is just me. There have been times where I've sat there staring at code for 2+ hours and am so frustrated I'm throwing things around the office - so I decide to go home or work on something else and come back to it the next day with a fresh perspective...only to find that it was indeed just me and I made a mistake that, for whatever reason, I was unable to find (typically it's a very small mistake!). There will be times where you'll make a mistake and go "DOH! I knew better than that!" ![]() So long as you've tried to figure it out yourself and come to us with some code in hand, myself and others will always be happy to help. I just don't like to spend any time helping those who want us to do their work for them or teach them how to do things - but I go out of my way to teach those who show effort and want to learn...
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
![]() |
| Thread Tools | |
|
|