HTML form to email, with a url redirect
Posted 04 October 2006 - 07:50 AM
I am working on a script to process a HTML form, email the results back to me and forward the use onto our Paypal Subscription Payment page.
Here's the form:
<form action="request.php" method="post">
Name: <input type="text" name="username" size"30">
Initials: <input type="text" name="userinit" size"30">
Email: <input type="text" name="useremail" size"30">
Company: <input type="text" name="usercomp" size"30">
Address: <textarea name="useraddr" cols"30" rows”8”>
Position: <input type="text" name="userpos" size"30">
Areas of responsibility: <textarea name="userarea" cols"30" rows”8”>
Current SW Version: <input type="text" name="uservers" size"30">
Addon Packages Used: <input type="text" name="useraddon" size"30">
Do you wish to be included in our Newsletter Mailing list?:
<input type="radio" name="usernews" value="yes"> Yes
<input type="radio" name="usernews" value="no"> No
Do you consent for your details to be made available to other members of the SWUGOM?:
<input type="radio" name="userconsent1" value="yes"> Yes
<input type="radio" name="userconsent1" value="no"> No
Do you consent for your details to be made available to our Presenters and Sponsors?:
<input type="radio" name="userconsent2" value="yes"> Yes
<input type="radio" name="userconsent2" value="no"> No
<input type="submit" value="Send Form">
and here'e the PHP script:
$url = "http://www.paypal.co.uk";
$username = $_POST['username'];
$userinit = $_POST['userinit'];
$useremail = $_POST['useremail'];
$usercomp = $_POST['usercomp'];
$useraddr = $_POST['useraddr'];
$userpos = $_POST['userpos'];
$userarea = $_POST['userare'];
$uservers = $_POST['uservers'];
$useraddon = $_POST['useraddon'];
$usernews = $_POST['usernews'];
$userconsent1 = $_POST['userconsent1'];
$userconsent2 = $_POST['userconsent2'];
$to = "email@example.com";
$re ="SWUGOM Membership Registration Form";
$msg = $username, $userinit, $usermail, $usercomp, $useraddr, $userpos, $userarea, $uservers, $useraddon, $usernews, $userconsent1, $userconsent2;
mail ( $to, $re, $msg );
header ( "Location:$url" ) ;
When you click on the sumbit button at the end of the form, the script runs and redirects the user to Paypal, no problem, but I never reveive an email.
Can anyone offer any help. I even bought a book & followed there advice, still no email......
Cheers - in advance........
Posted 04 October 2006 - 08:34 AM
have you got a smtp server running on your machine? If you are running linux then get postfix/sendmail running (you can tell by type typing mail in your terminal - and see if the command works). If you are running the other evil OS, then you need to install something like IIS for an smtp server. Otherwise you can try use a remote smtp server in the code below.
it may help to use the following
ini_set("SMTP", '127.0.0.1'); // or substitute this IP for a valid smtp server
mail ( $to, $re, $msg );
Posted 04 October 2006 - 09:12 AM
[code=php:0]$msg = $username, $userinit, $usermail, $usercomp, $useraddr, $userpos, $userarea, $uservers, $useraddon, $usernews, $userconsent1, $userconsent2;[code=php:0]
I believe it's known as a "Variable Variable", but not exactly sure if it's syntaxed properly.
Posted 04 October 2006 - 11:45 AM
To concat strings you need to use a .
I'm not 100% sure exactly what you want it to look like but im sure you need some sort of whitespace so here are a few suggestions:
to out them together,each value being on a new line: (\n = new line, \t for a tab)
$msg = "$username\n$userinit\n$usermail\n$usercomp\n$useraddr\n". "$userpos\n$userarea\n$uservers\n$useraddon\n$usernews\n$userconsent1\n$userconsent2;
or just spaces between them
$msg = "$username $userinit $usermail $usercomp $useraddr.....
to just concat two strings you can use: $newstr = $str1 . $str2; or $newstr = "$str1$str2"; php will figure out thats its a variable within a string - however you should use double quotes when joining strings or adding special characters such as \n
Posted 04 October 2006 - 12:11 PM
Will give that a try, seems logical now I've seen it in a working example.
Just to note from your previous response. My site is Hosted by Streamline.net. Will your suggestion for the SMTP script still work? I don't have access to the catual PHP ini file on there server.
Well, this is where my knowledge grinds to a holt. If I can't access the ini file, will this SMTP script do the job? I understand that it modifies the script with my SMTP Server info, sends the mail& then returns the ini back to it's original configuration.
If I don't have an ini file available, can I ceate one?
Posted 04 October 2006 - 01:05 PM
i think if you dont have access to the actual php.ini file, then you cant create another or anything... but yes using ini_set temporarily overrides what is specified in the ini file, and will return it to normal.
I imagine there will be a mail server set up on the machine so using localhost or 127.0.0.1 should work. using another smtp server might work if they dont require logon for smtp services.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users