Jump to content

theredking

Members
  • Posts

    48
  • Joined

  • Last visited

Everything posted by theredking

  1. Ah, ok. I am sending via POST though, what options does that leave me with?
  2. Ok thanks. I have tried this, and it echoes "array" instead of the value of the checkboxes... any ideas?
  3. I'm making great progress with my first real php form processing project, but I've come a little unstuck. I'm trying to echo the results from a checkbox. Currently I have <?php echo "$checkbox"; ?> This works, but if multiple selections are made, it only echoes one of them. How do I fix this? Thank you in anticipation!
  4. Ok. Seems to make more sense to be consistent and underscore in both places. Thank you for your help!
  5. Actually adding the underscore in the attribute does appear to translate the non-underscored name from the input box on the html form. So, <input type="text" name="First Name"> Can be called with: $first_name = $_REQUEST['First_Name'] ; Is this a safe practice? Or should I underscore both? Thanks
  6. Ok, cool thanks... So that means I will need to underscore in the html form names too, adding the underscore in the php file won't just translate that? Easy enough to do. Thank you all. Like I said, I'm learning, so it's good to learn this basics first!!
  7. Ok, cool, if that's the answer I'm fine with that... I'm trying to graduate away from FormMail, which did allow the spaces in input names. I can live with underscoring stuff instead, but I just wanted to check I wasn't doing anything wrong. Thanks!
  8. Hi thanks, yes I have. My form looks like this <form action="form_handler.php" method="post"> First Name: <input name="First Name" type="text" /><br> Last Name: <input name="Last Name" type="text" /><br> <input type="submit" /> </form>
  9. Sorry, couldn't think of a more appropriate subject. I'm trying to teach myself to write a simple form which submits the data to itself for validation, and then emails the confirmed entries to an email address, before forwarding on to a URL... I can do these things separately by copy and pasting code, but as I really want to understand how it works, I'm trying to write the code and make a combination of all those things... Ok, far too much back story already, I just wanted you to know I wasn't just asking all the time, I'm actually trying to learn for myself... So, I'm sure this is embarrassingly simple. I have my html form with text boxes mainly, "First Name" "Last Name" etc... This posts to my php file and the php file then has: $first_name = $_REQUEST['First Name'] ; etc... I then have echo to display all that... However it appears that it won't do this with ['First Name'], as it doesn't like the space between the words... I didn't think that the space mattered as long as it was the same name as the input box on the html form. If I change both to be ['First'] then it works. Why is this? I understand that you can't have spaces in a $variable, but I thought I could have spaces in ['this bit'] What is that called by the way? I'm still learning terminology too. Anyway, thank you in anticipation. It's a steep learning curve, but I'm enjoying the climb!
  10. I'm sorry, I'm an idiot, I see now what is wrong... I left the "\n\nhtmlentities(stripslashes($line1), ENT_QUOTES);\n$line2"" in the: mail( "[email protected]", "Email Subject", "$title $name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nStar Size: $star\n\nEngraving will read...\n\nhtmlentities(stripslashes($line1), ENT_QUOTES);\n$line2", "From: $name <$email>" ); So obviously it was sending it through to me that way... Agggh Actually though it will be very useful to have the email sent as html so I can style it a little nicer. Thank you so much for your time. As always, two heads are better than one, and it was only when I saw you repost my code that I could see the error in it. Regards, Rory
  11. Me again, sorry... I added what you suggested before the "mail(" like so: <?php } else { $line1=htmlentities(stripslashes($line1), ENT_QUOTES); $line2=htmlentities(stripslashes($line2), ENT_QUOTES); mail( "[email protected]", "Email Subject", "$title $name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nStar Size: $star\n\nEngraving will read...\n\nhtmlentities(stripslashes($line1), ENT_QUOTES);\n$line2", "From: $name <$email>" ); } if ($star == "4 inch $150"){ ?> and it turned all the punctuation characters into html numbers... "&#39;" etc... So I thought maybe now I can change the echo statements back to the simple "echo $line1" This fixed the echo displays, but meant the email now displayed: htmlentities(stripslashes(Mr Test&#039;s), ENT_QUOTES); <<item>> Instead of: Mr Test's <<item>> I then put what you suggested at the start of that php statement, and that gave me back my "\" in the echo, but fixed the html numbers in the email, but left $line1 of the email as: htmlentities(stripslashes(Mr Test's), ENT_QUOTES); If I add back in your echo statement, it fixes the echo again, but changes the email to displaying as: htmlentities(stripslashes(Mr Test\'s), ENT_QUOTES); for the information in $line1 Note the return of "\" Sorry if this is a terribly complicated post... Do you have any suggestions? Just to try and help my code now looks like this: <?php $line1=htmlentities(stripslashes($line1), ENT_QUOTES); $line2=htmlentities(stripslashes($line2), ENT_QUOTES); } else { mail( "[email protected]", "Email Subject", "$title $name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nStar Size: $star\n\nEngraving will read...\n\nhtmlentities(stripslashes($line1), ENT_QUOTES);\n$line2", "From: $name <$email>" ); } if ($star == "4 inch $150"){ ?> <?php echo htmlentities(stripslashes($line1), ENT_QUOTES); ?> <?php echo htmlentities(stripslashes($line2), ENT_QUOTES); ?>
  12. Thank you!! I'm learning fast. This forum is a great resource.
  13. ??? Ok, one more quick question... The contents of this form is also being emailed to me, and I'm having the same problem with the email results. Here's the code... I tried adding your suggestions to this code, but I'm afraid I'm a bit too green still to work it out properly. It's the $line1 and $line2 variables that are affected. Thanks again if you get the time... <?php } else { mail( "[email protected]", "Subject", "$title $name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nStar Size: $star\n\nEngraving will read...\n\n$line1\n$line2", "From: $name <$email>" ); } if ($star == "4 inch $150"){ ?>
  14. MadTechie and thorpe, thank you for your replies. The following fixed the problem... echo htmlentities(stripslashes($line1), ENT_QUOTES); thorpe what do you mean by magic quotes? Is there something else I should look for? Also MadTechie, I didn't add the "stripslashes()" that you suggested because I wasn't sure where to put it, but it works regardless. Should I still try to put that somewhere? Thanks again both of you. I really appreciate your help.
  15. Thank you, that works! What I want it to do though is echo exactly what is input into the text area, no matter what that is. For example, if "><><Wow's><><<" is input, only "><><><<" is echoed. How do I tell it to do that? Thanks!
  16. I have an echo that presents the content of a text box from a form. Trouble is, if within that text area someone types an apostrophe, for example "Owner's" it is echoed as such "Owners\'s" How can I stop it adding in the additional "\" character? Here's the code <?php echo ("$line1"); ?>
  17. Ah ha! I think I've stumbled across the solution by troubleshooting.... <?php } else { mail( "[email protected]", "Email Subject Goes Here", "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage...\n\n$line1\n$line2", "From: $name <$email>" ); } if ($radio == "4") $redir = "http://www.mysite.com/1.html"; elseif($radio == "6"){ $redir = "http://www.mysite.com/2.html"; } header("Location:$redir"); ?>
  18. Sorry, I'm sure this is a simple error I am making, or just a blatant misunderstanding, but I have now changed my code to look like this... and it is telling me I am getting a parse error because of an unexpected "}" <?php } else { mail( "[email protected]", "Star of Tomorrow purchase", "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage\n\n$line1\n$line2", "From: $name <$email>" ); } $radio = $_GET['radio']; if ($radio == "value1") $redir = "http://www.mysite.com/1.html"; }elseif($radio == "value2"){ $redir = "http://www.mysite.com/2.html"; }elseif($radio == "value3"){ $redir = "http://www.mysite.com/3.html"; } header("Location:$redir"); ?> The unexpected "}" character appears on this line: }elseif($radio == "value2"){ Thanks for the prompt reply!
  19. Hi, I'm still very new to this, but trying to learn quickly... I want to use sendmail to send me form data, and then redirect to different URLs (in this specific case different Paypal buy now buttons) with the click of one button, based on which radio button is selected. I have the form set up and working, but I can't work out what I need to edit to change the way the form is handled based on which 1 of 3 radio buttons is selected... I still want to receive the contents of the form (Name, Address, etc.) to the specified email address, but I want it to appear to seamlessly move to the correct page once the "submit" button is clicked. I've tried searching to teach myself how to do this, but I've hit a bit of a brick wall. Any help would be greatly appreciated. Thank you in anticipation... I assume it is the header section of this snippet of the sendmail code that I will need to be altering? <?php } else { mail( "[email protected]", "Subject of email", "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage\n\n$line1\n$line2", "From: $name <$email>" ); header( "Location: http://www.mywebsite.com/thank-you.html" ); } ?>
  20. Great, thanks! So this is also preventing the page from submitting on page load? Should I leave both solutions in place?
  21. I'm sorry, I'm not sure I understand, although I think I read something about this earlier. So the hidden input would submit a unique ID to the database, and the database would ignore any information with the same ID? I assume I would need to create another field in my database to deal with that? Am I close??
  22. FANTASTIC! Thank you very much!
  23. Hello all, I'm very new to this... A friend has helped me get this far, but as he is currently unavailable I've been trying to trouble shoot for myself. I have a simple form that sends information to a MYSQL database, with the intention of it populating an html table elsewhere. This it does. The problem is that the form submits upon page load, before any data is input, and before the submit button has been clicked. How do I stop this? I know I could put some required fields coding in there, and I will in time, but I don't want a user to see this when they first hit the page. I've tried reading the POST REDIRECT GET tutorials, but I just don't understand how to implement that. I don't want to prevent multiple submissions, but I do want to prevent duplicate submissions. Right now, a page reload will resend the information. Thank you in anticipation... here's the page <html> <head> <title>Test</title> </head> <body> <?php require ('connect.php'); if (isset($_POST)) { $var1 = $_POST['company']; $var2 = $_POST['city']; $var3 = $_POST['state']; $var4 = $_POST['friam']; $var5 = $_POST['fripm']; $var6 = $_POST['satam']; $var7 = $_POST['satpm']; $var8 = $_POST['sunam']; $var9 = $_POST['sunpm']; $var10 = $_POST['monam']; $var11 = $_POST['monpm']; $var12 = $_POST['ti']; $var13 = $_POST['tr']; $var14 = $_POST['we']; $var15 = $_POST['emc']; $var16 = $_POST['website']; $var17 = $_POST['email']; $query="INSERT INTO `registeredcompanies` (`company`,`city`,`state`,`friam`,`fripm`,`satam`,`satpm`,`sunam`,`sunpm`,`monam`,`monpm`,`ti`,`tr`,`we`,`emc`,`website`,`email`) VALUES ('$var1','$var2','$var3','$var4','$var5','$var6','$var7','$var8','$var9','$var10','$var11','$var12','$var13','$var14','$var15','$var16','$var17')"; $result = mysql_query ( $query ); if (empty($result)) { $output .="Error"; } else { $output .="Database Updated"; mysql_close(); } echo $output . "<br><br>"; } ?> <form name="registeredcompanies" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" > Company:<input type="text" name="company" size="24"> City:<input type="text" name="city" size="24"> State:<select name="state" size="1"> <option>-Select-</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="DC">Washington, DC</option> <option value="WV">West Virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> <option value="Non-US">Outside US</option> </select> <p>Friday AM:<input type="checkbox" name="friam" value="x"> PM:<input type="checkbox" name="fripm" value="x"></p> <p>Saturday AM:<input type="checkbox" name="satam" value="x"> PM:<input type="checkbox" name="satpm" value="x"></p> <p>Sunday AM:<input type="checkbox" name="sunam" value="x"> PM:<input type="checkbox" name="sunpm" value="x"></p> <p>Monday AM:<input type="checkbox" name="monam" value="x"> PM:<input type="checkbox" name="monpm" value="x"></p> <p>Tech Interviews:<input type="checkbox" name="ti" value="x"> Tech Resumes Only:<input type="checkbox" name="tr" value="x"> Watching Equity:<input type="checkbox" name="we" value="x"> Offer EMC:<input type="checkbox" name="emc" value="x"></p> <p>Website: <input type="text" name="website" size="24"></p> <p>Email: <input type="text" name="email" size="24"></p> <p><input type="submit" name="submitButtonName"></p> </form> </body> </html>
×
×
  • Create New...

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.