![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| 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 |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Apr 2008
Location: England
Posts: 11
OS: XP Pro SP2
|
Driving me crazy!
Hi People, I wonder if I can pick your brains...
Firstly I've never coded in PHP before so this is all new to me... I need a simple form filled out online, that can be submitted. I came up with this; but its not working, no mail, no nothing! please help! Code:
<form id="rwform" class="contactform" method="post" action="sendmail.php"> <div id="contactform"> <label for="name">Name</label> <input type="text" name="name" id="user" value="" /> </div> <div id="contactform"> <label for="address">Address</label> <input type="text" name="address" id="user" value="" /> </div> <div id="contactform"> <label for="telephone">Telephone</label> <input type="text" name="telephone" id="user" value="" /> </div> <div id="contactform"> <label for="email">Email Address:</label> <input type="text" name="email" id="emailaddress" value="" /> </div> <div id="contactform"> <label for="enquiry">Enquiry:</label> <textarea name="enquiry" id="enquiry" rows="5" cols="25"></textarea> </div> <div id="contactform"> <label for="hearaboutus">How did you hear about us?</label> <input type="checkbox" name="websearch" /> Web Search<br /> <input type="checkbox" name="recommended" class="threepxfix" /> Recommended<br /> <input type="checkbox" name="mag_ad" class="threepxfix" /> Magazine Advert<br /> <input type="checkbox" name="flyer" class="threepxfix" /> Flyer<br /> </div> <div style="margin-left: 150px;"> <input type="submit" value="Submit" /> <input type="reset" value="reset" /> </div> </form> Code:
<?php
$_POST = array_map('strip_tags', $_POST);
$name = $_REQUEST['name'] ;
$address = $_REQUEST['address'] ;
$telephone = $_REQUEST['telephone'] ;
$email = $_REQUEST['email'] ;
$enquiry = $_REQUEST['enquiry'] ;
$websearch = $_REQUEST['websearch'] ;
$recommended = $_REQUEST['recommended'] ;
$mag_ad = $_REQUEST['mag_ad'] ;
$flyer = $_REQUEST['flyer'] ;
mail("myaddress@mail.co.uk", "Web Enquiry Contact", "From: $email", $name, $address, $telephone, $enquiry, $websearch, $recommended, $mag_ad, $flyer);
header( "Location: http://www.example.com/thankyou.html" );
?>
Many thanks!!! |
|
|
|
|
|
#2 (permalink) |
|
Registered User
Join Date: Jul 2007
Posts: 468
OS: Win Vista Home Premium
|
Re: Driving me crazy!
in the html you use the id "contactform" multiple times, i'm sure thats not correct usage, it may work but i thought an id was supposed to be unique...
i'm sorry i can't remember a lot of PHP so i don't know the problem, when you do get it sorted though you could start to stop spamming using basic javascript on your html page: change <input type="submit" value="Submit" /> to <input type="submit" value="Submit" onSubmit="this.disabled=true;" /> i think .disabled is the property, (the button should grey out after having been clicked) so that when one set of information has been submitted the user can not re-submit the data without having re-loaded the page first. This will only stop people from clicking the submit button a million times when the page loads slowly (and submitting the data millions of times). On the PHP side of things i don't know what you'd do to stop spamming, but i'm sure contact/query boxes aren't spammed a lot are they? Hope any of this helped, Jamey |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Apr 2008
Location: Oklahoma City
Posts: 26
OS: xp(sp2), OSX(10.5)
|
Re: Driving me crazy!
yes ids should be unique, if you are doing this for css style then replace id="contactform" with class="contactform" in the html and change the declaration from #contactform{} to .contactform{} in the css. I have bearly looked at php but two things I would check are first do you have smtp setup on the server (or what ever it uses) and a variable is enclosed in quotes in mail(), you may have to concatenate the string with the variable.
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Apr 2008
Location: England
Posts: 11
OS: XP Pro SP2
|
Re: Driving me crazy!
Ok I did a search on these boards in an attempt to get the correct code in place... I have however come up against a problem (not the one that doesn't make it work, that still exists!) I dont know how to incorporate any of the other fields I've got...'how did they hear about us' fields!
I know I shouldn't expect a message as such, but an email at the least! Anyone???? Current HTML with previous advice taken. ![]() Code:
<form id="rwform" method="post" action="sendmail.PHP"> <div class="contactform"> <label for="name">Name</label> <input type="text" name="name" value="" /> </div> <div class="contactform"> <label for="address">Address</label> <input type="text" name="address" value="" /> </div> <div class="contactform"> <label for="telephone">Telephone</label> <input type="text" name="telephone" value="" /> </div> <div class="contactform"> <label for="email">Email Address:</label> <input type="text" name="email" value="" /> </div> <div class="contactform"> <label for="enquiry">Enquiry:</label> <textarea name="enquiry" id="enquiry" rows="5" cols="25"></textarea> </div> <div class="contactform"> <label for="hearaboutus">How did you hear about us?</label> <input type="checkbox" name="websearch" /> Web Search<br /> <input type="checkbox" name="recommended" class="threepxfix" /> Recommended<br /> <input type="checkbox" name="mag_ad" class="threepxfix" /> Magazine Advert<br /> <input type="checkbox" name="flyer" class="threepxfix" /> Flyer<br /> </div> <div style="margin-left: 150px;"> <input type="submit" value="Submit" onSubmit="this.disabled=true;" /> <input type="reset" value="reset" /> </div> </form> Code:
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!
$sendto = "myemail@host.co.uk"; // for example: username@usershost.com
$gotopage = "http://www.example.com/thankyou.html"; // for example: http://www.yoursite.com/thankyou.html
// end editable variables
$_POST = array_map('strip_tags', $_POST);
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// let's format them
$message = "Enquiry:" . "\n\n" . $message;
$subject = "Email From Website - " . $name;
// this will show you who it's from AND will blind carbon-copy the message to them
$headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n";
$headers .= 'Bcc: ' . $name . '<' . $email . '>' . "\r\n";
// let's check if that email is valid or not!
// if it's valid - send the email
mail($sendto, $subject, $message, $headers);
header("Location: $gotopage");
?>
Last edited by Cerilia : 04-24-2008 at 04:18 AM. |
|
|
|
|
|
#6 (permalink) |
|
Design Team Member
|
Re: Driving me crazy!
No big deal - you're just learning...and you're doing fine. I did notice that last PHP script was a chopped up version of mine :P
The biggest part you did wrong in your first script was not putting all of your form elements together to create the message. PHP Code:
Here's what I have come up with. I tested it out, should work for you. PHP Code:
Don't worry about not knowing what things mean in this...that's why I'm here...I can explain anything you need clarification on. I try to keep the scripts I post here simple - but sometimes I have to put something a bit more complex, so don't feel that you're supposed to know how to do any of it :P
__________________
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 | |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: Apr 2008
Location: England
Posts: 11
OS: XP Pro SP2
|
Re: Driving me crazy!
Redcore I am indebted, many many thanks...
![]() But after uploading your code I still cant receive any feedback emails (Yes I did change addresses )!Now I have trawled through my hosts vast database of support questions and I found this. Can I assume that in merely place this code; Code:
Sendmail Functions What is the path to Sendmail? /usr/sbin/sendmail -fuser\@domainname.co.uk You need to replace -fuser\@domainname.co.uk with a valid mailbox on your account: ie -froot\@yourdomain.co.uk You must leave in the -f and make sure there is a \ before the @ An example of how to use this is displayed below: mail($to, $sub, $mess, "From: root@yourdomain.co.uk", "-froot@yourdomain.co.uk"); Code:
// send the mail
mail($sendto, $subject, $message, $headers, * Place code here? *);
//header("Location: $gotopage");
|
|
|
|
|
|
#8 (permalink) |
|
Design Team Member
|
Re: Driving me crazy!
That shouldn't affect it sending out. I tested with the email "nobody@nowhere.com"
__________________
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 | |
|
|
|
|
|
#10 (permalink) |
|
Design Team Member
|
Re: Driving me crazy!
Yeah, it worked flawlessly on my server. Could you send me the actual page you got that reference from above? I don't think that should affect the server sending a message, but I can look into it more.
__________________
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 | |
|
|
|
|
|
#11 (permalink) |
|
Registered User
Join Date: Apr 2008
Location: England
Posts: 11
OS: XP Pro SP2
|
Re: Driving me crazy!
Well surprise, surprise it worked when I added that code! Weird!
I have a problem though, the thank you page is not displaying? The address is correct, so what am I missing? |
|
|
|
|
|
#12 (permalink) |
|
Registered User
Join Date: Apr 2008
Location: England
Posts: 11
OS: XP Pro SP2
|
Re: Driving me crazy!
Sorry Redcore....I cant edit the above message. It seems I didn't add a space... added and now works perfectly.
Thank you Redcore for all your help. You are a credit to this forum. Cheers! |
|
|
|
|
|
#14 (permalink) |
|
Design Team Member
|
Re: Driving me crazy!
What doesn't work - the form, the emailing, or the thank you page?
__________________
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 | |
|
|