Jump to content

Archived

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

rmprmp

HTML form to email, with a url redirect

Recommended Posts

I am 100% New to PHP and have read that many postings and tutorials, you wouldn't believe me if I told you....

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">

</form>



and here'e the PHP script:



<?php

$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 = "members@swugom.co.uk";
$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........

Share this post


Link to post
Share on other sites
hi

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

[color=blue]ini_set("SMTP", '127.0.0.1'); // or substitute this IP for a valid smtp server
mail ( $to, $re, $msg );
ini_restore("SMTP");[/color]

cheers,
tdw

Share this post


Link to post
Share on other sites
Thanks for that TDW, having looked over my code, could you or someone confirm tha tthi sline in the PHP script is correct:

[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.

Cheers,

rmprmp

Share this post


Link to post
Share on other sites
Hi

To concat strings you need to use a [color=blue].[/color]

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)
[code]
$msg = "$username\n$userinit\n$usermail\n$usercomp\n$useraddr\n".
              "$userpos\n$userarea\n$uservers\n$useraddon\n$usernews\n$userconsent1\n$userconsent2;
[/code]

or just spaces between them
[code]
$msg = "$username $userinit $usermail $usercomp $useraddr.....
[/code]

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

Cheers,
tdw

Share this post


Link to post
Share on other sites
Hi,

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?

Cheers,

rmprmp

Share this post


Link to post
Share on other sites
hi

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.

Cheers,
tdw

Share this post


Link to post
Share on other sites

×

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.