PHP - Form Question
Hi
I would like to know how to make a form where a person can enter an email of a couple of friends. I have looked on the internet and I'm not finding anything. Can someone help. Thank you Similar TutorialsI have read around and can't seem to find the right coding for what I need on this forum and some other other forums. I have a contact form (as listed below) and I need 2 locations (Print Name and Title) fields to auto-populate on a separate form (can be a doc, pdf, etc. any form of document which is easiest) and this form can be totally back end and the individual using the form never is going to see the form. It's going on a contract form, that we would like to auto-populate. Also is there a simple attachment code so individuals can attach documents to the code? <p style: align="center"><form action="mailtest.php" method="POST"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> <div align="center"> <p class="style1">Name</p> <input type="text" name="name"> <p class="style1">Address</p> <input type="text" name="address"> <p class="style1">Email</p> <input type="text" name="email"> <p class="style1">Phone</p> <input type="text" name="phone"> <p class="style1">Debtor</p> <input type="text" name="debtor"> <p class="style1">Debtor Address</p> <input type="text" name="debtora"> <br /> <br /> <a href="authoforms.php" target="_blank" style="color:#ffcb00" vlink="#ffcb00">Click here to view Assignment Agreement and Contract Agreement</a> <p class="style1"><input type='checkbox' name='chk' value='I Have read and Agree to the terms.'> I have read and agree to the Assignment and Contract Agreement <br></p> <p class="style1">Print Name</p> <input type="text" name="pname"> <p class="style1">Title</p> <input type="text" name="title"> <p class="style1">I hear by agree that the information I have provided is true, accurate and the information I am submitting is <br /> not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms:</p> <select name="agree" size="1"> <option value="Agree">Agree</option> <option value="Disagree">Disagree</option> </select> <br /> <br /> <p class="style1">Employee ID:</p> <input type="text" name="employee"> <br /> <input type="submit" value="Send"><input type="reset" value="Clear"> </div> </form> </p> The mailtest php is this ?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; $phone = $_POST['phone']; $debtor = $_POST['debtor']; $debtora = $_POST['debtora']; $value = $_POST['chk']; $pname = $_POST['pname']; $title = $_POST['title']; $agree = $_POST['agree']; $employee = $_POST['employee']; $formcontent=" From: $name \n Address: $address \n Email: $email \n Phone: $phone \n Debtor: $debtor \n Debtor's Address: $debtora \n 'Client' has read Assignment and Contract Agreement: $value \n Print Name: $pname \n Title: $title \n I hear by agree that the information I have provided is true, accurate and the information I am submitting is not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms: $agree \n \n Employee ID: $employee \n IP: $ip"; $recipient = "mail@crapower.com"; $subject = "Online Authorization Form 33.3%"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!" . " -" . "<a href='index.php' style='text-decoration:none;color:#ffcb00;'> Return Home</a>"; $ip = $_POST['visitoraddress'] ?> I have a simple form: Code: [Select] <form name="form1" method="post" action="login.php"> <p> <label>Username: <input type="text" name="username"> </label> </p> <p><label>Password: <input type="password" name="password"> </label></p> <p><label>Organization Code: <input type="text" name="organization"> </label></p> <p><font size="2" face="Verdana"> <input type="submit" name="submit" id="submit" value="Login"> <br> </font> </span></p> </form> What I want to do is change the action of the form based on the input of organization. Example: Code: [Select] if($_POST['organization'] == 'test'){ action="../application/test/display/login.php" } How would I do this where it works? Thanks! Hello,
I'd like to know how could I make a form with infinite elements and send it to mysql.
Example:
<div class="templatemo-input-icon-container"> <i class="fa fa-info-circle"></i> <input type="text" class="form-control" id="name" name="sname" value="<? echo $dataname; ?>" placeholder="Person name"> </div>I have this code which I can very easily put to work and send the sname value to a mysql database. My problem now is that I don't know how many persons the user whats to add, for that reason I'd like to add a button called Add Person, and if the user clicks it, it will appear like a new copy of this div. I've seen on the google that I can use HTML DOM createElement() to create this textboxes, but, if I do, how can I get their values if I don't know their name's or id's etc? and also how could I create an Element with classes? PS: I'd like to make this without having to reload the page. Thanks, Joao Lourenco. I want my PHP code to display and handle a form. If the form hasn't been submitted it needs to display the form. If the form has been submitted but the data couldn't be validated then I want to display the same form (with the user's data intact). If the form has been submitted and the data was validated then it handles the form and prints a message. The problem I seem to be having is that I have nested conditionals that both need to execute the same code. I cant seem to wrap my head around it. I have a search box with an input box. When the user enters a string in this box and then when it clicks submit, the form needs to go to the http://ww.mywebsite.com/wp-content/uploads/<?php echo $_POST["name"]; ?>.jpg where $_POST["name"] is what the user entered. how to make it work?? <form action="http://ww.mywebsite.com/wp-content/uploads/<?php echo $_POST["name"]; ?>.jpg" method="post" target="_blank"> <!-- form fields here --> <INPUT TYPE = "Text" NAME = "name"> <input type="submit" /> </form> Can I replace the set message text for $body and $subject with $_POST['message']; $_POST['subject']; so I can get a users input from a html form via php as the action. Instead of the set text in the script. As seen http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm Hey Everyone, My website asks for an email address when one registers but I want to put a limit it on it (like to register you gotta have an email address from a specific domain). How can I edit the form input to do this? Any help will be greatly appreciated, thanks -STG Up until now, I have been writing Forms that submit back to themselves. Now I want to break up my code. I usually have this PHP at the top of my forms... Code: [Select] <?php // ******************************************** // HANDLE FORM. * // ******************************************** if ($_SERVER['REQUEST_METHOD']=='POST'){ // Form was Submitted (Post). If I change my Form Action to point to another script, will this code work in that new script?? (In other words, will Script_B be able to detect $_SERVER['REQUEST_METHOD']=='POST' ??) Thanks, Debbie My question is, when someone make same html form with action that goes on same php file on my server, so i need to know, can my site be hacked in that way ? I mean if i have form that goes on file /sources/add_user.php and when someone make same html form that goes on www.my-site.com/sources/add_user.php and in that way to add users on my baze ? hello. i want to know what is *$ or +$ because i see it in many contact forms. also, what is the difference between these: /^[A-Z]+[a-z]*$/ /^[A-Z]+[a-z]+$/ /^[A-Z]+[a-z]$/ /^[A-Z]+[a-z]/ also, which is the shortest and efficient method of checking somebodys name to be exactly "Name Surname" - "Green Trancer" ? in my form, i use var filter = /^[A-Z]+[a-z]*$/; var filter2 = /^[A-Z]+[a-z]+\s+[A-Z]+[a-z]+$/; and then i check the name to be like filter or filter2. how can i check that between the words to be exactly one space character ? thank you very much. HI there, i'm using a flash and php form. The problem lie in the PHP I only seem to get the field titles (Name and telephone) coming through and not the data they contain. Could somebody tell me what i'm doing wrong? <?php $sendTo = "myemail@gmail.com"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ".$strtelephone."\r\n"; $message .= "message: ".$strmessage."\r\n"; mail($sendTo, $subject, $message, $headers); ?> thank you
Below is my contact from - and I have set anti spam question as I don't like captcha. How to I code the post/human bit so it is case insensitive?
<div class="one-half-column-right" id="contactform"> <form method="post" action="index.php#contactform"> <label>Name*</label> <div class="clear"></div> <input name="name" placeholder="Type Here"> <label>Email*</label> <div class="clear"></div> <input name="email" type="email" placeholder="Type Here"> <label>Message</label> <textarea name="message" placeholder="Type Here"></textarea> <label>*If today is Tuesday, what is tomorrow? <br> [lowercase answer please]<br> (Anti-spam)</label> <input name="human" placeholder="Type Here"> <input id="submit" name="submit" type="submit" value="Submit"> </form> <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Website Form'; $to = ‘name@name.com’; $subject = 'website form enquiry'; $human = $_POST['human']; $headers .= 'From: '.$from."\r\n". 'Reply-To: '.$from."\r\n" . 'X-Mailer: PHP/' . phpversion(); $body = "From: $name\n E-Mail: $email\n Message:\n $message"; if ($_POST['submit'] && $human == ‘wednesday’) { if (mail ($to, $subject, $body, $from)) { echo '<p style="font-family: Montserrat, Helvetica, Arial, sans-serif; font-weight: 600; text-align:center; font-size: 16px; color: #000; text-transform: uppercase; background-color: #FFD700"> Request has been sent. We will get back to within 48 hours!<br></p>'; } else { echo '<p style="font-family: Montserrat, Helvetica, Arial, sans-serif; font-weight: 600; text-align:center; font-size: 16px; color: #000; text-transform: uppercase; background-color: #FFD700"> Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '') { echo '<p style="font-family: Montserrat, Helvetica, Arial, sans-serif; font-weight: 600; text-align:center; font-size: 16px; color: #000; text-transform: uppercase; background-color: #FFD700"> You answered the anti-spam question incorrectly!</p>'; } ?> <!--// form //-->
Hi all, I have heard stories that hackers/viruses or basically something that you don't want uploaded to a server through a website form have been able to type some sort of code in to a html form field to access information. I know how to control the length of fields, how to validate that an email address is in the correct format etc. - but when it comes to having a textfield for the user to add up to 2000 characters of their own words, how can I protect from malicious code being inserted? The textfield is located inside the user area but anyone can join, so anyone ultimately can enter code! Thanks for the help. Hello, freaks. I need a little help with the best way to go about this. I have a field in mysql that contains a comma separated string of values. What I need to do is get those values out of the db and list them into editable text fields so the user can update the values in a html form. So far this is my code, I left out all the in betweens - validation, results, etc - for this post...but its there . SELECT servs FROM services WHERE id = $a_id $services = $row['servs']; $srvs = explode(',', $services); Then for the form: <?php foreach ($srvs as $service) { ?> <input type="text" name="servs[]" value="<?php echo $service ?>" /> <?php } ?> This gives me a text field for each value of servs, great! But the problem is, the user can enter up to 15 servs. Some currently have less than that saved in the db. I want to give them the ability to 1. edit any of the current servs value and 2. add more values if they have less than 15. My question is, how do I echo out 15 editable text fields for servs[] no matter the number of values they currently have? And when I go to implode the values, will blank text fields screw everything up? I can't find anything in the forums that relate to this. I believe it probably will involve $i, but I am not too familiar with counting in php yet, so I could really use some help. Thanks! Oh - and I am not stuck on using text fields, but I couldn't figure how to make this work using a select list or checkboxes. Any suggestions either way would help. Alright, I am struggling to get back into the world of programming. I have background in C++ and Javascript, but this was 7 years ago. I am now trying to develop a plugin for a wordpress website I manage and am having a simple problem. It seems like it is at least. Here is what I need to accomplish. I am designing a plugin that generates a random string of text on a wordpress page. It uses a shortcode to return a form onto the page where it is placed. The form has 3 elements, a textbox, a dropdown list, and a submit button. I can do all of this so far. Here is where I am a bit lost. When the submit button is pressed, I need it to run a function passing the value selected in the dropdown list. I would like this to be contained on the same page. So I am not sure what I need to put in the action="", and my guess is I would use the post method. The function that generates the text returns a paragraph. So it would function like this... $paraText = genParagraph($txtType); //txtType would be the drop down value Currently, I do this and return the value (after slightly more processing). My guess is I have to use the $_POST[] function to somehow return the data into the text box on the page. I am not exactly sure how to achieve this. Thank you for your help! Hi Guys I have built a simple form, which has text fields Name, Telephone Number, Best Time to Call and E-mail. For security purposes, I am testing each against the function shown below which looks for dangerous code snippets, in an effort to protect against email header injection attacks. When it comes to the E-mail field, I am not actually testing whether a valid e-mail address has been entered, as it is the telephone number which is essential, not the e-mail. My question is, do you think this is a security weakness? Many thanks Code: [Select] //http://www.tonyspencer.com/2005/12/15/email-injection-exploit-through-a-php-contact-form/ //preg_match string to match goes within forward slashes, i.e. /str/, and i at the end makes it case insensitive function containsInjectionAttempt($input) { if (preg_match("/\r/i", $input) || preg_match("/\n/i", $input) || preg_match("/%0a/i", $input) || preg_match("/%0d/i", $input) || preg_match("/Content-Type:/i", $input) || preg_match("/<script>/i", $input) || preg_match("/bcc:/i", $input) || preg_match("/to:/i", $input) || preg_match("/cc:/i", $input)) { return true; } else { return false; } } If I wanted to make multiple fields required before letting a User move past the field is this the proper way to do it? Code: [Select] if(isSet($_POST['playerFirst']['playerLast']['feet']['inches']['year']['status'])) { ## Something } else { ## Something else } Someone parses the html login form and gets the csrf token from hidden field. Now can he request with that csrf token to login through jquery ajax? Hi, I m doing some work for my self an because of that i been reading a lot arround about PHP, and theres something that i would like to ask a bit of enlightenment. So my question is as the title says about html form's using php to insert data into mysql, i been reading tutorials arround the interwebs and even made afew successful tests, but pretty much all tutorials use 2 files to accomplish this the html file with the form and an insert.php where the actual code is stored so this made me think is this how usually it's done? in over all you will have 1 file for the form, 1 for the insert, 1 for the edit php code and 1 for delete. How do you guys usually do it? PS: one of the tests i did was making 1 single file with all these using an switch. My interest in making this question is solo to learn how other people do it to see if i m in the right way. Thanks in advance. |