Hello there, newb to the forums here I wouldnt consider myself a newbie in general but i still have a whole lot to learn. Im familiar with PHP scripting but i definitely wouldnt call myself an expert quite yet. I have a website that i've hosted some forms/contracts on that use php to return the data to me in email form. I've tried to use the same PHP script that I use for my contact us page as a template for the php for all my forms/agreements-just editing them a bit. The problem that i've run into is when a user clicks submit, I want it to obviously return to me all of the input data the user has typed in all of the text fields, as well as a couple radio button values. My problem is that when i recieve the email, it will only send me one field value at a time...for example I only recieve the user's name in my email when I should be collecting their name, address, credit card, etc......This was never a problem for my contact page because the only input field is the body of the message anyway. also, when the data is returned to me I need a better way of organizing it; right now if it sends me back someones name for example, it will simply say in the first and only line of my email message: John Smith. I would like it to say Name: John Smith, in other words Iwould like to receive the data in the closest form possible to the way i distributed it. if I ask for an email on my form i want it to come back as Email: email@email.com <?php $name = trim($_POST['name']); $location = trim($_POST['location']); $city = trim($_POST['city']); $zip = trim($_POST['zip']); $home = trim($_POST['home']); $cell = trim($_POST['cell']); $office = trim($_POST['office']); $primaryfax = trim($_POST['primaryfax']); $local = trim($_POST['local']); $localfax = trim($_POST['localfax']); $from = trim($_POST['from']); $problem = trim($_POST['problem']); $previousproblem = trim($_POST['previousproblem']); $company = trim($_POST['company']); $service = trim($_POST['service']); function checkEmail($from) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $from)) { return FALSE; } list($Username, $Domain) = split("@",$from); if(getmxrr($Domain, $MXHost)) { return TRUE; } else { if(fsockopen($Domain, 25, $errno, $errstr, 30)) { return TRUE; } else { return FALSE; } } } if( isset( $_POST['submit'] ) || !empty( $_POST['submit'] ) ) { $errors = ''; if(checkEmail($from) == FALSE) { if( empty($from) ) { $errors .= "<br/><strong>Please enter a valid Email address</strong><br/><br/>"; } else { $errors .= "<strong>Your E-mail address entered is not valid, please go back and try again.<br/><br/></strong>"; } } if ( empty($name) ) { $errors .= "<strong>Please enter your full name.<br/><br/></strong>"; } if ( empty($location) ) { $errors .= "<strong>Please enter a valid service call location.<br/><br/></strong>"; } echo $errors; if ( empty($errors) ) { $sendTo = "me@ my site .com"; $subject = SCAF; $headers = "From: " . $from; $message = $name;$location; mail($sendTo, $subject, $message, $headers); header("location: http://www. mysite. com/thanks.html"); } } ?> PHP: any help would be greatlyyyyyy appreciated. thank you! also: the value named $service represents 3 radio buttons, each with a different value....how do i correctly return the data for a radio button using the same php script?thank you
As far as the message variable, separate the values with commas and use the $POST[]. The semi-colon signifies the end of a statement.
thank you very much for taking the time to reply....If you could possibly just type out what I should replace line 71 with, as I keep getting this error: Parse error: parse error, unexpected ',' in /home/1/6/0/18120/18120/public_html/scaf.php on line 71 line 71 is the message variable...I changed it to: $message = $POST[$name], $POST[location]; PHP: just to test it
Taking into consideration that the post is a variable, it should indeed be a dot. Sorry for the misguide.
general ray or premiumscripts, thank you for checking out my thread and replying.... I was wondering if either of you could edit my code and show me exactly how to fix it. using the dot as described, i now recieve a blank email when the user hits submit....i feel so close but so far
You're familiar with PHP yet you don't know how to access an array? Your code: $message = $POST[$name], $POST[location]; PHP: Should be: $message = $_POST['name'] . "\r\n\r\n" . $_POST['location']; PHP: That's alot of errors.. $POST instead of $_POST $name as the key instead of the string 'name' location as they key insteazd of the string 'location' Now grab yourself a PHP book and read it..
Wow Premium thank you for your quick response. I know i definitely need to brush up on php, I've only written a few of them before....that's why i'm here:for help. Your code worked thank you for solving a problem thats been bugging me for 2 hours. Now do you think you could possibly help me with just the rest of this code.....the only 2 problems i have left are: I need to organize the responses better, on the email i recieve, it only sends whatever the user typed...i want it to be labeled. for example i want my email to look like this: Name: john smith Email hisemail @ website. com location: his location etc.... also, I need to know how to get the values of the radio buttons in my responses. Ideally, the responses would look like what i typed above, and then have the radio button values listed in bold or something....I need the user to be able to pick which credit card type they use and then whether or not they accept terms and conditions, both using radio buttons. can you please help me? I really appreciate it. here's my form code if it helps: <form name=contactform action=scaf.php method=post> <table> <tr><br> <tr><td colspan="3" style="font-weight: bold; text-align: center; text-decoration: underline; ">Service Call Authorization</td></tr> <td align=left>Name:</td> <td width="15"> </td> <td><input size=35 maxlength=35 type=text name=name style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Service Location:(street address)</td> <td width="40"> </td> <td><input size=35 maxlength=35 type=text name=location style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>City & State:</td> <td> </td> <td><input size=30 maxlength=30 type=text name=city style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Zip code:</td> <td> </td> <td><input size=10 maxlength=10 type=text name=zip style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Primary Residence:</td> <td> </td> <td><input size=35 maxlength=35 type=text name=residence style="font-family: Courier New; font-size: 10pt"></td></tr> <tr><td><B><U>Contact Information</U></B></td></tr> <tr> <td align=left>Home Phone:</td> <td> </td> <td><input size=15 maxlength=15 type=text name=home style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Cell Phone:</td> <td> </td> <td><input size=15 maxlength=15 type=text name=cell style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Office Phone:</td> <td> </td> <td><input size=15 maxlength=15 type=text name=office style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Primary Fax:</td> <td> </td> <td><input size=15 maxlength=15 type=text name=primaryfax style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Local Phone:</td> <td> </td> <td><input size=15 maxlength=15 type=text name=local style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Local Fax:</td> <td> </td> <td><input size=15 maxlength=15 type=text name=localfax style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Email:</td> <td> </td> <td><input size=35 maxlength=35 type=text name=from style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Describe the problem:</td> <td> </td> <td><input size=35 maxlength=35 type=text name=problem style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Have you encountered any other problems in the past year?:</td> <td> </td> <td><input size=35 maxlength=35 type=text name=previousproblems style="font-family: Courier New; font-size: 10pt"></td></tr> <tr> <td align=left>Has another person or company worked on your pool/spa in the past year? If so, who?:</td> <td> </td> <td><input size=35 maxlength=35 type=text name=company style="font-family: Courier New; font-size: 10pt"></td></tr> <tr><td colspan="3" style="text-align: center; ">Some repairs require an initial diagnostic visit. What would you like us to do?</td></tr> <tr><td><Input type = 'Radio' Name ='Service' value= 'Diagnostic'>Diagnostic Call Only.</td></tr> <td><Input type = 'Radio' Name ='service' value= 'repair550'>Diagnostic & repair under $550.</td></tr> <td><Input type = 'Radio' Name ='service' value= 'repair800'>Diagnostic & repair up to $800.</td></tr> <td><Input type = 'Radio' Name ='service' value= 'fixit'>Do whatever it takes to fix it.</td></tr> <tr><td><a href="scafterms.html">Click Here to see the complete terms and conditions of our Service Call Authorization Form.</a> <tr> <td> </td> <td> </td> <td><input type=submit value=" Submit " name=submit style="font-size: 10pt; font-family: Tahoma"></td></tr> </table> </div> </form> HTML: Please help, I promise if you do I'll go pick up that book on PHP asap!