PHP - Feedback Form, Get Function Not Grabbing Info From Url.
Hello. Basically the issue I am having is my feedback form is not grabbing the Company Name and ID from the URL. I have the php code set in place where it's supposed to post, but it's not getting it. Can someone please help me out? I'm pretty new with php, so I'm kind of at the brink of my knowledge.
Thanks, Jess. Code: [Select] <?php //Modified because only email is required //if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) { if (empty($_POST['email'])) { $error_msg .= "E-mail is a required field. \n"; } elseif (strlen($_POST['name']) > 15) { $error_msg .= "The name field is limited at 15 characters. Your first name or nickname will do! \n"; } elseif (!ereg("^[A-Za-z' -]*$", $_POST['name'])) { $error_msg .= "The name field must not contain special characters. \n"; } elseif (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",strtolower($_POST['email']))) { $error_msg .= "That is not a valid e-mail address. \n"; } elseif (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i', $_POST['url'])) $error_msg .= "Invalid website url."; if ($error_msg == NULL && $points <= $maxPoints) { $subject = "Feedback for " . $_POST['Company']; $message = "You received this e-mail message through your website: \n\n"; foreach ($_POST as $key => $val) { $message .= ucwords($key) . ": $val \r\n"; } $message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n"; $message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n"; $message .= 'Spam points: '.$points; if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) { $headers = "From: $yourEmail \r\n"; $headers .= "Reply-To: {$_POST['email']}"; } else { $headers = "From: $yourWebsite <$yourEmail> \r\n"; $headers .= "Reply-To: {$_POST['email']}"; } if (mail($yourEmail,$subject,$message,$headers)) { echo '<p>Thank you for taking the time to send us your feedback. Your comments are appreciated and help us provide the most current and accurate information possible.</p> <p>If you require further assistance, please visit our <a href="http://www.domain.com/" target="_blank">contact us</a> page.</p>'; $sentmail = 1; echo ' <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("analyticscode"); pageTracker._setDomainName(".domain.com"); pageTracker._trackPageview(); </script> '; } else { echo '<p>Your mail could not be sent this time.</p>'; } } } function get_data($var) { if (isset($_POST[$var])) echo htmlspecialchars($_POST[$var]); } ?> <?php foreach( $_POST as $checkbox ){ echo $checkbox .'<br />'; $checkbox = array("WebsiteLinkIsNotAccurate", "TelephoneNumberIsNotAccurate", "FaxNumberIsNotAccurate", "CompanyIsOutOfBusiness", "CompanyIsNoLongerAtThisLocation", "CompanyDoesNotProvideTheProductOrServiceAsFeatured", "Other(PleaseExplainBelow)"); } ?> <?php // DISPLAY ERROR MESSAGE - CHECK TO SEE IF USER HAS SUBMITTED THE FORM SUCCESSFULLY if ($error_msg != NULL) { echo '<p><strong style="color: red;">ERROR:</strong><br />'; echo nl2br($error_msg) . "</p>"; } if($sentmail == 0){ ?> <form id="feedback" name="feedback" method="post" action="feedback.php" onSubmit="return CheckForm()"> <noscript> <p><input type="hidden" name="nojs" id="nojs" /></p> </noscript> <input type="hidden" name="CompanyID" id="CompanyID" value="<?php echo $_POST['companyid']; ?>"> <input type="hidden" name="Company" id="Company" value="<?php echo $_POST['companyname']; ?>"> <p><strong>If you have different information about <u><?php echo $_POST['companyname']; ?></u>, or were unable to contact them, please let us know by completing the form below.</strong></p> ... Similar TutorialsI was wanting to make my own version of TinyURL for my personal use. So far, the only way I can get it to work as trim as possible is using the format: http://www.mysite.com/?tag TinyURL can do http://tinyurl.com/tag instead. I know dropping the ? is a trifling thing, but I'd like to figure out how they did it. I could do it by just creating subfolders and dropping an index.php in there that does a redirect, but I wasn't sure if there was a more efficient way....? Hello Guys, I have a question I have the following function that is located in a different file. I want to be able to use the $lat and $long in my main page how would I code it? Code: [Select] function toCoordinates($all_address) { $bad = array( " " => "+", "," => "", "?" => "", "&" => "", "=" => "" ); $all_address = str_replace(array_keys($bad), array_values($bad), $all_address); $data = new SimpleXMLElement(file_get_contents("http://maps.google.com/maps/geo?output=xml&q={$all_address}")); $coordinates = explode(",", $data->Response->Placemark->Point->coordinates); return array( "latitude" => $coordinates[0], "longitude" => $coordinates[1] ); } Tried this but it didn't work $all_address2 = toCoordinates($all_address); echo "$all_address2; Please advise... Thanks, Dan Hi guys really need some help. i have got this function. I am learning codeignitor. function uploadify() { $file = $this->input->post('filearray'); $data['json'] = json_decode($file); print_r($data); $name = $json->{'file_name'}; $this->files->add($name); $this->load->view('uploadify',$data); } this is the result i get from the print_r(). Array ( [json] => stdClass Object ( [file_name] => footer-icpn229.jpg [real_name] => footer-icpn2.jpg [file_ext] => .jpg [file_size] => 1.75 [file_path] => /home/codeig/public_html/files/footer-icpn229.jpg [file_temp] => /home/codeig/tmp/phpSupCpi ) ) What i am trying to do is pull the value filename out off the array and pass it into another vairable in the fucntion which is what i am trying to do with these two lines of code. $name = $json->{'file_name'}; $this->files->add($name); I keep getting this error what am i doing wrong? Undefined variable: json The following code used to work in PHP 4, but it no longer works under PHP 5. Can someone take a look and let me know what needs fixing please? I'm not new to PHP, but I'm not an expert. Code: [Select] <? // Set page variables. $title = "Feedback Form"; $back = ""; $bg = '000066'; $text = 'ffffff'; $link = 'ffff00'; $vlink = 'ff0000'; $trans = 'spinoutin'; $btntag = 'text=000070 insetselection'; $txtbxtag = 'bgcolor=ffffff text=000070 cursor=ff autoactivate nohighlight'; $ip = $_SERVER['REMOTE_ADDR']; // Remove < and > from the email message. $msg = str_replace("<","",$msg); $msg = str_replace(">","",$msg); // Set email variables. $your_email = 'email@mydomain.com'; $your_name = 'Joe Blogs'; $your_link = 'http://www.mydomain.com/'; $confirm_sub = 'Message Sent'; $confirm_msg = "Hi $feedbackname, Thank you for your email message sent from the $sub. I will respond to it as quickly as I can. Thanks again, $your_name $your_link"; $contact_msg = "$feedbackname ($feedbackemail) wrote: $msg $ip"; // Begin the sendmail routine. if ($send) { if (!$feedbackname || !$feedbackemail || substr_count($feedbackemail, '@') < 1 || substr_count($feedbackemail, '.') < 1 || !$sub || !$msg || substr_count($spam, 'clark') < 1) { print <<<EOF <html> <title>Error!</title> <body background="$back" bgcolor="$bg" text=$text link=$link vlink=$vlink transition=$trans fontsize=medium> <center> <br><br> <font s=7 c=f0><b> Error!</b></font> <p> Please go back and correct the errors listed below: <p> <table> <tr><td> <ul> EOF; if (!$feedbackname) { print "<li>Your name is missing!<br>"; } if (!$feedbackemail || substr_count($feedbackemail, '@') < 1 || substr_count($feedbackemail, '.') < 1) { print "<li>Your email is missing or invalid!<br>"; } if (!$sub) { print "<li>The email subject is missing!<br>"; } if (!$msg) { print "<li>The email message is missing!"; } if (substr_count($spam, 'clark') < 1) { print "You need to correctly type in the Anti-Spam word. Hit Back and try again."; } print <<<EOF </ul> </table> <p> <A href="feedback.php">Back</A> <br><br><br><br> </center> </body> </html> EOF; } else { // Email that gets sent to you. mail($your_email, $sub, $contact_msg, "From: $feedbackname < $feedbackemail >"); // Email that gets sent to them. mail($feedbackemail, $confirm_sub, $confirm_msg, "From: $your_email"); // Print the thank you page. print <<<EOF <html> <head><title>Message Sent</title> </head> <body background="$back" bgcolor="$bg" text=$text link=$link vlink=$vlink transition=$trans> <H2>Feedback</H2> Thanks $feedbackname for sending your message to me!<P> You will receive a confirmation email momentarily.<P> </body> </html> EOF; } } else { // Print the contact form page. print <<<EOF <H3>Feedback Form</H3> To send an email to me simply fill out the form below.<P> <form method=post> Name: <input name=feedbackname $txtbxtag size=40><P> Email: <input name=feedbackemail $txtbxtag size=40><P> <INPUT type="hidden" name="sub" value="Feedback Form"> Message:<br> <textarea name=msg rows=10 cols=50 maxlength=500 $txtbxtag></textarea><P> <IMG SRC="images/sh-layout/turing.jpg" WIDTH="100" HEIGHT="30" BORDER="0" ALT="turing"><BR> Anti-Spam Measure - In lowercase letters, retype the word in the image above:<BR> <input name=spam $txtbxtag size=40><P> <INPUT TYPE=submit NAME=send $BTNTAG VALUE="Send"><BR> </form> EOF; } ?> Hi there, I'm trying to add a feedback form to my website, so that people can send me emails directly from my site. I found this code on another website, which works fine except that when the sender doesn't enter their reply email address it still sends it anyway - which is what this code is supposed to prevent. This is the code: <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail( "myname@mydomain.com", "Subject: $subject", $message, "From: $email" ); echo "Your message has been sent"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='feedback.php'> Your Email Address: <input name='email' type='text' size='50' /><br /><br /> Subject: <input name='subject' type='text' size='50' /><br /><br /> Message:<br /> <textarea name='message' rows='15' cols='56'> </textarea><br /> <input type='submit' name='sendEMail' value='Send Email' /> </form>"; } ?> Am I supposed to redirect the user to another page? I want it to simply say "please enter your email address" next to the email field box if the user forgets to enter it. Please help. Help! I'm stuck! This is the feedback form file I made. Code: [Select] <html> <head><title>Bob's Auto Parts - Customer Feedback</title></head> <body> <h1>Customer Feedback</h1> <p>Please tell us what you think.</p> <form action="processfeedback.php" method="post"> <p>Your name:<br/> <input type="text" name="name" size="40" /></p> <p>Your email address:<br/> <input type="text" name="email" size="40" /></p> <p>Your feedback:<br/> <textarea name="feedback" rows="8" cols="40" wrap="virtual" /></textarea></p> <p><input type="submit" value="Send feedback" /></p> </form> </body> </html> And this is the process feedback file I made. Code: [Select] <?php //create short variable names $name = trim($_POST['name']); $email = trim($_POST['email']); $feedback = trim($_POST['feedback']); //set up some static information $toaddress = "wolocaw@localhost"; $subject = "Feedback from web site"; $mailcontent = "Customer name: ".$name."\n". "Customer email: ".$email."\n". "Customer comments:\n".$feedback."\n"; $fromaddress = "From: webserver@example.com"; //invoke mail() function to send mail mail($toaddress, $subject, $mailcontent, $fromaddress); ?> <html> <head> <title>Bob's Auto Parts - Feedback Submitted</title> </head> <body> <h1>Feedback submitted</h1> <p>Your feedback (shown below) has been sent.</p> <p><?php echo nl2br($mailcontent); ?> </p> </body> </html> After I fill out the form, it brings me to a page that says "Feedback submitted" at the top and "Your feedback (shown below) has been sent." below it. And that's it. nl2br($mailcontent) doesn't do anything. What am I doing wrong? I don't understand! Hello: I have this form below that stores the data in a database, and sends an email to my client so he gets the information (And if there is a more proper way to code this, I am all ears): Code: [Select] <?php include('include/myConn.php'); ?> <html> ... <?php $error = NULL; $myDate = NULL; $ParentsName = NULL; $BestPhone = NULL; $Email = NULL; $StudentsName = NULL; $StudentsSchool = NULL; if(isset($_POST['submit'])) { $myDate = $_POST['myDate']; $ParentsName = $_POST['ParentsName']; $BestPhone = $_POST['BestPhone']; $Email = $_POST['Email']; $StudentsName = $_POST['StudentsName']; $StudentsSchool = $_POST['StudentsSchool']; if(empty($ParentsName)) { $error .= '<div style=\'margin-bottom: 6px;\'>- Enter the parent\'s name.</div>'; } if(empty($BestPhone)) { $error .= '<div style=\'margin-bottom: 6px;\'>- Enter the best phone number to reach you.</div>'; } if(empty($Email) || !preg_match('~^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$~',$Email)) { $error .= '<div style=\'margin-bottom: 6px;\'>- Enter a valid email.</div>'; } if(empty($StudentsName)) { $error .= '<div style=\'margin-bottom: 6px;\'>- Enter the student\'s name.</div>'; } if(empty($StudentsSchool)) { $error .= '<div style=\'margin-bottom: 6px;\'>- Enter the student\'s school.</div>'; } if($error == NULL) { $sql = sprintf("INSERT INTO mySignUpData(myDate,ParentsName,BestPhone,Email,StudentsName,StudentsSchool) VALUES ('%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($myDate), mysql_real_escape_string($ParentsName), mysql_real_escape_string($BestPhone), mysql_real_escape_string($Email), mysql_real_escape_string($StudentsName), mysql_real_escape_string($StudentsSchool); if(mysql_query($sql)) { $error .= '<div style=\'margin-bottom: 6px;\'>Thank you for using the sign-up sheet.</div>'; mail( "me@mywebsite.com", "Sign-up Sheet Request", "Date Sent: $myDate\n Parent's Name: $ParentsName Best Phone: $BestPhone Email: $Email Student's Name: $StudentsName Student's School: $StudentsSchool\n ", "From: $Email" ); unset($ParentsName); unset($BestPhone); unset($Email); unset($StudentsName); unset($StudentsSchool); } else { $error .= 'There was an error in our Database, please Try again!'; } } } ?> <form name="myform" action="" method="post"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> <div id="tableFormDiv2"> <fieldset> <hr /> </fieldset> <fieldset><span class="floatLeftFormWidth2"><span class="textErrorItalic">* - Required</span></span> <span class="floatFormLeft"> </span></fieldset> <?php echo '<span class="textError">' . $error . '</span>';?> <fieldset><span class="floatLeftFormWidth2"><span class="textErrorItalic">*</span> Parent's Name:</span> <span class="floatFormLeft"><input type="text" name="ParentsName" size="45" maxlength="50" value="<?php echo $ParentsName; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth2"><span class="textErrorItalic">*</span> Best Phone # To Reach You:</span> <span class="floatFormLeft"><input type="text" name="BestPhone" size="45" maxlength="50" value="<?php echo $BestPhone; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth2"><span class="textErrorItalic">*</span> Email:</span> <span class="floatFormLeft"><input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth2"><span class="textErrorItalic">*</span> Student's Name:</span> <span class="floatFormLeft"><input type="text" name="StudentsName" size="45" maxlength="50" value="<?php echo $StudentsName; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth2"><span class="textErrorItalic">*</span> Student's School:</span> <span class="floatFormLeft"><input type="text" name="StudentsSchool" size="45" maxlength="50" value="<?php echo $StudentsSchool; ?>" /></span></fieldset> </div> <input type="submit" name="submit" value="Click here to submit your registration form" class="submitButton2" /><br /> </form> </html> I want to add a feature that will also send an autoresponder email with a message to the user who submitted the form. How can that be done? Do I need to somehow revise this section: Code: [Select] mail( "me@mywebsite.com", "Sign-up Sheet Request", "Date Sent: $myDate\n Parent's Name: $ParentsName Best Phone: $BestPhone Email: $Email Student's Name: $StudentsName Student's School: $StudentsSchool\n ", "From: $Email" Please let me know and thanks in advance. Hello: I want to create a feedback form that will allow a user to select from 30 or so items on a page, and send the data to an email address. I think it's something like a shopping cart but without a need to process a payment. I want to list items (like a soccer ball, a basket ball, etc.) and allow the user to select the size of the ball, the color, the number of balls, etc. I want the user to be able to select 1 item or many items. Once they are done, they would hit submit, and the data would get sent to an email address. Do I need to use a session to do this? I was trying to work with this code: Code: [Select] <?php session_start(); session_register('product'); session_register('amount'); $_SESSION['product'] = $_POST['product']; $_SESSION['amount'] = $_POST['amount']; //SEND THE EMAIL CODE HERE ???? ?> <form method="post" action=""> <input type="text" size="10" name="product"><br /> <input type="text" size="10" name="amount"><br /> <input type="submit" value="Finish"> </form> But I'm pretty sure I'm not in the ballpark on how to do this. Anyone have any ideas? Thanks in advance. Hi. Can someone show me the proper way to do a feedback form (like a "Contact US" form). I have read about SQL injections and would like to know I am protecting against it. And the proper way to store the submitted data in a database for a client's records. I have a basic form I use, but I am unable to store the data properly. Any help or a code idea would be appreciated. Thanks much. Hello: Did my first post last week and am new to PHP. Making the jump from Classic ASP into PHP. I got some good advice last time. I have a feedback form I have been using, and it works fine for sending results to the website owner. How can I add to it so it will first add all the data to mySQL database, and then email the results to the site owner? Also, I hear about SQL injection attacks a lot - is my current code safe from that? This is what I have: contact.php Code: [Select] ... <form method="post" name="myform" action="sendmail.php"> Full Name: <input type="text" name="FullName" /> Address: <input type="text" name="Address" /> City: <input type="text" name="City" /> State: <input type="text" name="State" /> Zip: <input type="text" name="Zip" /> Phone: <input type="text" name="Phone" /> Email: <input type="text" name="Email" /> Website: <input type="text" name="Website" /> Comments: <textarea cols="43" rows="6" name="Comments"></textarea> <input type="submit" /><br /> </form> ... sendmail.php Code: [Select] <?php $FullName = $_REQUEST['FullName'] ; $Address = $_REQUEST['Address'] ; $City = $_REQUEST['City'] ; $State = $_REQUEST['State'] ; $Zip = $_REQUEST['Zip'] ; $Phone = $_REQUEST['Phone'] ; $Email = $_REQUEST['Email'] ; $Website = $_REQUEST['Website'] ; $Comments = $_REQUEST['Comments'] ; mail( "info@website.com", "Contact Request", "Full Name: $FullName\nAddress: $Address\n City: $City\n State: $State\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Website: $Website\n Comments: $Comments\n", "From: $Email" ); header( "Location: http://www.website.com/thanks.php" ); ?> Any help or coding examples would be most appreciated! Thanks! Hi again: What I want to do - and am stuck on - is to allow the user to add files to the feedback, submit the form, and the data will get stored in the DB (and the uploaded files will get stored in "uploads"), plus an email will get sent to the client who can click the files links in the email, and download them that way. I have done this via ASP, but never tried it with PHP ... This is what my database table looks like" Code: [Select] CREATE TABLE `myProductRightData2` ( `myDate` varchar(55) default NULL, `myNameAndProduct` text, `myWebsite` text, `myProductUse` text, `myProductProblemSolver` text, `myProductUnique` text, `myWhyBetter` text, `myProductAppeal` text, `myProductSelling` text, `myProductResearch` text, `file1` varchar(255) default NULL, `myProductStory` text, `mySpokesperson` text, `myProductReviewed` text, `myProductDecision` text, `file2` varchar(255) default NULL, `file3` varchar(255) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `myProductRightData2` -- INSERT INTO `myProductRightData2` VALUES('February 22, 2011', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test.pdf', 'test', 'test', 'test', 'test1.jpg', 'test2.jpg'); And this is the form code: Code: [Select] <?php $error = NULL; $myDate = NULL; $myNameAndProduct = NULL; $myPhone = NULL; $myEmail = NULL; $myWebsite = NULL; $myProductUse = NULL; $myProductProblemSolver = NULL; $myProductUnique = NULL; $myWhyBetter = NULL; $myProductAppeal = NULL; $myProductSelling = NULL; $myProductResearch = NULL; $file1 = NULL; $myProductStory = NULL; $mySpokesperson = NULL; $myProductReviewed = NULL; $myProductDecision = NULL; $file2 = NULL; $file3 = NULL; if(isset($_POST['submit'])) { if ((($_FILES["file1"]["type"] == "image/gif") || ($_FILES["file1"]["type"] == "image/jpg") || ($_FILES["file1"]["type"] == "image/jpeg") || ($_FILES["file1"]["type"] == "image/pjpeg")) && ($_FILES["file1"]["size"] < 20000)) { if ($_FILES["file1"]["error"] > 0) { echo "Return Code: " . $_FILES["file1"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file1"]["name"] . "<br />"; echo "Type: " . $_FILES["file1"]["type"] . "<br />"; echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file1"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file1"]["name"])) { echo $_FILES["file1"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file1"]["tmp_name"], "upload/" . $_FILES["file1"]["name"]); echo "Stored in: " . "uploads/" . $_FILES["file1"]["name"]; } } } else { echo "Invalid file"; } $myDate = $_POST['myDate']; $myNameAndProduct = $_POST['myNameAndProduct']; $myPhone = $_POST['myPhone']; $myEmail = $_POST['myEmail']; $myWebsite = $_POST['myWebsite']; $myProductUse = $_POST['myProductUse']; $myProductProblemSolver = $_POST['myProductProblemSolver']; $myProductUnique = $_POST['myProductUnique']; $myWhyBetter = $_POST['myWhyBetter']; $myProductAppeal = $_POST['myProductAppeal']; $myProductSelling = $_POST['myProductSelling']; $myProductResearch = $_POST['myProductResearch']; $file1 = $_POST['file1']; $myProductStory = $_POST['myProductStory']; $mySpokesperson = $_POST['mySpokesperson']; $myProductReviewed = $_POST['myProductReviewed']; $myProductDecision = $_POST['myProductDecision']; $file2 = $_POST['file2']; $file3 = $_POST['file3']; if(empty($myNameAndProduct)) { $error .= '-- Enter your Name and Product. <br />'; } if(empty($myPhone)) { $error .= '-- Enter your Phone Number. <br />'; } if(empty($myEmail)) { $error .= '-- Enter your Email. <br />'; } if($error == NULL) { $sql = sprintf("INSERT INTO myProductRightData2(myDate,myNameAndProduct,myPhone,myEmail,myWebsite,myProductUse,myProductProblemSolver,myProductUnique,myWhyBetter,myProductAppeal,myProductSelling,myProductResearch,file1,myProductStory,mySpokesperson,myProductReviewed,myProductDecision,file2,file3) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($myDate), mysql_real_escape_string($myNameAndProduct), mysql_real_escape_string($myPhone), mysql_real_escape_string($myEmail), mysql_real_escape_string($myWebsite), mysql_real_escape_string($myProductUse), mysql_real_escape_string($myProductProblemSolver), mysql_real_escape_string($myProductUnique), mysql_real_escape_string($myWhyBetter), mysql_real_escape_string($myProductAppeal), mysql_real_escape_string($myProductSelling), mysql_real_escape_string($myProductResearch), mysql_real_escape_string($file1), mysql_real_escape_string($myProductStory), mysql_real_escape_string($mySpokesperson), mysql_real_escape_string($myProductReviewed), mysql_real_escape_string($myProductDecision), mysql_real_escape_string($file2), mysql_real_escape_string($file3)); if(mysql_query($sql)) { $error .= 'Thank you for submitting your product. We will be in contact with you soon.'; mail( "m@sp.com", "Product Submission", "Date Sent: $myDate\n Name and Product: $myNameAndProduct\n Phone: $myPhone\n Email: $myEmail\n Website: $myWebsite\n Product Use: $myProductUse\n Problem Product Solves: $myProductProblemSolver\n Product Uniqueness: $myProductUnique\n Product Better Because: $myWhyBetter\n Product Appeal: $myProductAppeal\n Product Selling Places: $myProductSelling\n Product Research: $myProductResearch\n Research Documentation: $file1\n Product Story: $myProductStory\n Product Spokesperson: $mySpokesperson\n Product Reviewed: $myProductReviewed\n Product Decision Maker: $myProductDecision\n Samples: $file2\n $file3", "From: $Email" ); } else { $error .= 'There was an error in our database, please try again!'; } } } echo '<span class="textError">' . $error . '</span>'; ?> <form name="myform" action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> What is the name of your company and product? <textarea name="myNameAndProduct" cols="72" rows="1"><?php echo $myNameAndProduct; ?></textarea> What is your phone number? <textarea name="myPhone" cols="72" rows="1"><?php echo $myPhone; ?></textarea> What is your email? <textarea name="myEmail" cols="72" rows="1"><?php echo $myEmail; ?></textarea> website we can visit for more information? <textarea name="myWebsite" cols="72" rows="1"><?php echo $myWebsite; ?></textarea> What is this product used for? <textarea name="myProductUse" cols="72" rows="3"><?php echo $myProductUse; ?></textarea> Does this product solve a problem? If so, how? <textarea name="myProductProblemSolver" cols="72" rows="3"><?php echo $myProductProblemSolver; ?></textarea> Does your product have unique or cutting-edge features, ingredients or benefits? <textarea name="myProductUnique" cols="72" rows="3"><?php echo $myProductUnique; ?></textarea> What makes it better than similar products? <textarea name="myWhyBetter" cols="72" rows="3"><?php echo $myWhyBetter; ?></textarea> Does this product have mass appeal? Who is the target audience? <textarea name="myProductAppeal" cols="72" rows="3"><?php echo $myProductAppeal; ?></textarea> Is this product currently selling elsewhere? If so, where and what is the retail price? <textarea name="myProductSelling" cols="72" rows="3"><?php echo $myProductSelling; ?></textarea> Do you have independent research to prove claims about this product? Please provide copies. <textarea name="myProductResearch" cols="72" rows="3"><?php echo $myProductResearch; ?></textarea> Upload independent research copies (Word or PDF files): <input type="file" name="file1" id="file1" /> How and why did your company start? Does that "story" make this product more interesting? <textarea name="myProductStory" cols="72" rows="3"><?php echo $myProductStory; ?></textarea> Do you have a passionate spokesperson that would be comfortable presenting on TV? <textarea name="mySpokesperson" cols="72" rows="3"><?php echo $mySpokesperson; ?></textarea> Has this product ever been submitted to QVC for review? If yes, please provide the details. <textarea name="myProductReviewed" cols="72" rows="3"><?php echo $myProductReviewed; ?></textarea> Who from your company will make the decision to proceed if QVC is presents the right opportunity? <textarea name="myProductDecision" cols="72" rows="3"><?php echo $myProductDecision; ?></textarea> Upload two samples of your product for review (.JPG or PDF files): <input type="file" name="file2" id="file2" /> <input type="file" name="file3" id="file3" /> <input type="submit" name="submit" value="Submit New Product" class="submitButtonProduct" /><br /> </form> It's essentially the same feedback for I always use and it works fine, but I have been trying to integrate the upload portion into it from a tutorial I found on W3C: http://www.w3schools.com/PHP/php_file_upload.asp Any ideas on how to make this work? this is my code:
<?php include 'sqlconnect.php'; $sql = mysqli_query($con,"SELECT * FROM aktiviteter"); $data = array(); while ($row = mysqli_fetch_assoc($sql)) { $data[$row['id']] = array( 'title' => $row['title'], 'pris' => $row['pris'], 'beskrivelse' => $row['beskrivelse'], ); } print_r(error_get_last()); ?> <html> <head> <title>Polterplanner Bestilling</title> <link rel="stylesheet" type="text/css" href="style.css"> <script> var jsArray = []; <?php foreach($data as $key => $value): echo 'jsArray["'.$key.'"] = [];'; echo "\r\n"; foreach($value as $infoType => $info): echo 'jsArray["'.$key.'"]["'.$infoType.'"] = "'.$info.'";'; echo "\r\n"; endforeach; endforeach; print_r(error_get_last()); ?> function activitySelectionChanged(elementID) { var activitySelect = document.getElementById('activity' + elementID); var selectedValue = activitySelect.value; var priceOutputBox = document.getElementById('activityPrice' + elementID); priceOutputBox.innerHTML = jsArray[selectedValue]["pris"]; var price1 = document.getElementById('activityPrice').innerHTML; var price2 = document.getElementById('activityPrice2').innerHTML; var total = document.getElementById('activityTotal'); if(price1!='Pris' && price2!='Pris') { total.innerHTML = parseInt(price1) + parseInt(price2); } } </script> </head> <body> <div id"wrapper"> <div id="tableWrapper"> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="23"> <select class="styled-select" name="activity" id="activity" onChange="activitySelectionChanged('')"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; endforeach; print_r(error_get_last()); ?> </select></td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityPrice">Pris</span>,-</td> </tr> </table> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="23"> <select class="styled-select" name="activity2" id="activity2" onChange="activitySelectionChanged(2)"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; print_r(error_get_last()); endforeach; ?> </select></td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityPrice2">Pris</span>,-</td> </tr> </table> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="27">Total:</td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityTotal">Total</span>,-</td> </tr> </table> </div> <!-- tableWrapper ends --> </div> <!-- wrapper ends --> </body> </html>what i want is the info send through a form, so that im ale to send this via an email. would i use: document.getElementById( ...... ); ? link to working page: http://polterplanner.dk/bestiller.php Think I made a post about this earlier but doesn't show so dont think it posted successfully but if it did, my bad haha. Basicly I have a form which sends info to my database table after submitted. I added some form validation so when the user didn't enter a required field, text appears stating that the field needs to be entered. However, whether the field is entered or not, if the user submits the info still goes to the database. How do I fix it so that it only sends the info to the database once the required fields are entered? Do I go about it with an if statement? Heres my code up until now: Code: [Select] <?php if (isset($_POST['submit'])) { // forms inputs set to variables $cname = mysql_real_escape_string($_POST['cname']); $sname = mysql_real_escape_string($_POST['sname']); $init = mysql_real_escape_string($_POST['init']); $fname = mysql_real_escape_string($_POST['fname']); $title = mysql_real_escape_string($_POST['title']); $msname = mysql_real_escape_string($_POST['msname']); $dob = mysql_real_escape_string($_POST['dob']); $sex = mysql_real_escape_string($_POST['sex']); $lang = mysql_real_escape_string($_POST['lang']); $idno = mysql_real_escape_string($_POST['idno']); $telh = mysql_real_escape_string($_POST['telh']); $telw = mysql_real_escape_string($_POST['telw']); $cell = mysql_real_escape_string($_POST['cel']); $fax = mysql_real_escape_string($_POST['fax']); $email = mysql_real_escape_string($_POST['email']); $address = mysql_real_escape_string($_POST['address']); $errorstring =""; //default value of error string if (!$sname) $errorstring = $errorstring . "Surname<br>"; if (!$fname) $errorstring = $errorstring . "First name<br>"; if (!$title) $errorstring = $errorstring . "title<br>"; if (!$dob) $errorstring = $errorstring . "date of birth<br>"; if (!$sex) $errorstring = $errorstring . "sex<br>"; if (!$idno) $errorstring = $errorstring . "id number<br>"; if (!$email) $errorstring = $errorstring . "email address<br>"; if (!$address) $errorstring = $errorstring . "address<br>"; if ($errorstring!="") echo "Please fill out the following fields:<br>$errorstring"; else { //run code die("success!"); } // query $sql = "INSERT INTO student (sno, cname, sname, init, fname, title, msname, dob, sex, lang, idno, telh, telw, cel, fax, email, address ) VALUES ('', '$cname', '$sname', '$init', '$fname', '$title', '$msname', '$dob', '$sex','$lang', '$idno', '$telh', '$telw', '$$cell', '$fax', '$email', '$address')"; mysql_query($sql) or die('Error:' . mysql_error()); } mysql_close($link); ?> It's a project, first time I'm attempting form validation so this is rather new for me. With that being said, please feel free to give any tips and criticism as this is a learning curve for me. Also I'm probably going to add some security later for sql injection etc. so if anyone has some tips on that it would be great. Almost done with that damn project, thanks in advance I am trying to build a form that will process all the user inputted information, and put those contents into an html table so that I can send the info to both my customer and myself. I figured out how to send an email to myself as html, but the user email is arriving as plain text with all the html tags. Someone had suggested PHPMailer, but I cannot figure out how to format it properly to work with my setup. I am new to PHP so this is a learning curve. I have included a sample of my process form with fictitious email addresses. Any help is much appreciated. Thank you in advance for the help! Code: [Select] <?php header("Location: ../contactthank.php"); ?> <?PHP $field_Type = $_POST['field_Type']; $field_Service_Provider = $_POST['field_Service_Provider']; $field_Brand = $_POST['field_Brand']; $field_Model = htmlspecialchars($_POST['field_Model']); $field_Size = $_POST['field_Size']; $field_Charger = $_POST['field_Charger']; $field_Case = $_POST['field_Case']; $field_Software = $_POST['field_Software']; $field_Manual = $_POST['field_Manual']; $field_Box = $_POST['field_Box']; $field_Condition = $_POST['field_Condition']; $field_FirstName = htmlspecialchars($_POST['field_FirstName']); $field_LastName = htmlspecialchars($_POST['field_LastName']); $field_Email = $_POST['field_Email']; $field_ZipCode = (int)$_POST['field_ZipCode']; $field_Comments = $_POST['field_Comments']; ?> <?php $reference = (rand(100000000000,99999999999999)); echo $reference; ?> <?php $to = "email@mail.com"; $subject = "Submission# $reference"; $headers = 'From: $field_Email' . "\r\n"; $message = '<html> <head> <title>Cell Phone Form Submission</title> </head> <body> <h1>Thank you for your submission. We will get back to you shortly</h1> <table border="1"> <tr> <td>Reference#</td> <td>' . $reference . '</td> </tr> <tr> <td>I want to</td> <td><b>Sell</b></td> </tr> <tr> <td>Service Provider</td> <td>' . $field_Service_Provider . '</td> </tr> <tr> <td>Model</td> <td>' . $field_Model . '</td> </tr> <tr> <td>Size</td> <td> ' . $field_Size . '</td> </tr> <tr> <td>Accessories</td> <td>' . $field_Charger . " " . $field_Case . " " . $field_Software . " " . $field_Manual . " " . $field_Box . '</td> </tr> <tr> <td>Condition</td> <td>' . $field_Condition . '</td> </tr> <tr> <td>Name</td> <td>' . $field_FirstName . " " . $field_LastName . '</td> </tr> <tr> <td>Email</td> <td>' . $field_Email . '</td> </tr> <tr> <td>Zip Code</td> <td>' . $field_ZipCode . '</td> </tr> <tr> <td>Comments</td> <td>' . $field_Comments . '</td> </tr> </table></body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $user = "$field_Email"; $usersubject = "Form Submission# $reference"; $userheaders = "From: email@mail.com\n"; $usermessage = '<html> <head> <title>Form Submission</title> </head> <body> <h1>Thank you. We will get back to you shortly</h1> <table border="1"> <tr> <td>Reference#</td> <td>' . $reference . '</td> </tr> <tr> <td>I want to</td> <td><b>Sell</b></td> </tr> <tr> <td>Service Provider</td> <td>' . $field_Service_Provider . '</td> </tr> <tr> <td>Model</td> <td>' . $field_Model . '</td> </tr> <tr> <td>Size</td> <td> ' . $field_Size . '</td> </tr> <tr> <td>Accessories</td> <td>' . $field_Charger . " " . $field_Case . " " . $field_Software . " " . $field_Manual . " " . $field_Box . '</td> </tr> <tr> <td>Condition</td> <td>' . $field_Condition . '</td> </tr> <tr> <td>Name</td> <td>' . $field_FirstName . " " . $field_LastName . '</td> </tr> <tr> <td>Email</td> <td>' . $field_Email . '</td> </tr> <tr> <td>Zip Code</td> <td>' . $field_ZipCode . '</td> </tr> <tr> <td>Comments</td> <td>' . $field_Comments . '</td> </tr> </table></body> </html> '; mail($to,$subject,$message,$headers); mail($user,$usersubject,$usermessage,$userheaders,$headers); ?> I have a contact form with a file upload button, when you click on “submit” you are redirected on Paypal everything works fine but, I would like to send the contact form only when visitors have paid on Paypal. I’ve searched on google but I have not found a way to do this. Can anyone help? Cheers, Aidan. Hi I have tried and tried and tried again to get this to work
in simple terms I have very little knowledge with PHP and even less with mysql
I have a paid subscription and domain in order to learn more and I feel I have made ok progress so far
then I realised how unsafe my current work is;
here is my experience this far
I created a site for a group of voluntary online game hosts where they can posts points from their tournaments in a forum
and some info pages to go with this,
however what I did was create a base template and style sheet and then an admin dashboard linked to individual forms to allow the group admin to edit the info pages they go to my form and enter the desired info and submit this then sends through and action file which posts the text and <BR> to a .txt file,
then the connecting page reads the .txt file using the PHP code of " <? php include ( 'index.txt'); ?>
yes you are seeing this correctly I have allowed a direct edit of text in a .txt file rather silly of me but I didn't realise how unsafe this was until now I guess its a good job I trust that the admin has no knowledge or skills in coding
ok since all this I have created a DB in MySQL on my server,
My server uses PHPMyAdmin I have create a DB named " mnvbcou1_content1 " and a table named " home " with rows " ID " and " home "
what I am trying to do:
I want my page to display the content of the table row home and a form once submitted to send to the table row home
or if needed I can re make this DB if the names are not suitable
I have tried to create the needed coding to make this work but for some reason this just will not work I have already added 2 rows to my table to try and make the page to display the content but it just is not working I got an error every time
so I hope that someone out there is rather patient and is willing to help me learn how to do this correctly and safely,
also this is a closed group website the address to this site is only known by a handful of none programmers I am mainly trying to make this work for my own personal knowledge and server safety please help me
I am trying to have a search bar and this is the search results page. However when they search they have the option to type in anything and it will search the entire directory for what ever they type in so if they type in "Dog" I want dog to be searched for in the database under title and author this is the code I have now...can anyone help me?? Code: [Select] // Build SQL Query $query = "select * from videos where title like \"%$trimmed%\" order by id DESC"; // EDIT HERE and specify your table and field names for the SQL query I think this belongs here, but my $_POST['gender'] won't grab the gender that was submitted through a form. I am using AJAX so the page doesn't have to reload so it can go in a smooth transition, but the AJAX is grabbing the value perfectly fine. I have a feeling the $_POST isn't grabbing the value because the page isn't reloading.. but I don't want to reload it. These codes are all on the same page. Here is my Javascript: Code: [Select] <script> function chooseGender() { var gender = $('input[name=gender]:checked', '#submitgender').val(); if(gender) { $.ajax( { type: "POST", url: window.location.pathname, data: gender, success: function() { alert("You have chosen to be a " + gender); //It's grabbing it perfectly fine! $("#submitgender").hide(); //It hides the gender table so they can't choose a gender since they already have chosen one. $("#rest").fadeIn(); //Shows the other table that's labeled "rest" as it's ID so they can choose what base, eyes, etc for that specific gender they've chosen. } }); } else { alert('Select a gender.'); } } $(function tabs() { $( "#tabs" ).tabs(); }); </script> But here is the PHP inside the #rest table: Code: [Select] <?php $gender = $_POST['gender']; $sql = "SELECT * FROM habases WHERE gender='".$gender."'"; $result = mysqli_query($cxn, $sql) or die(mysqli_error($cxn)); print_r($sql); while ($row = mysqli_fetch_assoc($result)) { $baseimage = $row['image']; $baseskin = $row['skin']; echo "<img src=\"http://www.elvonica.com/".$baseimage."\" value=\"".$baseskin."\">"; } ?> And this is what I'm getting for the print_r: Quote SELECT * FROM habases WHERE gender='' Currently I am using this very popular code to get all the football scores: Code: [Select] $title = $params->get('title'); $fontc = $params->get('fontc'); $fonts = $params->get('fonts'); //this array contains sports and their URLs $sports = array( "NFL" => "http://sports.espn.go.com/nfl/bottomline/scores"); $results = array(); foreach ( $sports as $sport => $url ) { //get the page pointed to by $url $page = file_get_contents($url); //grab all variables out of the page preg_match_all("/&([^=]+)=([^&]+)/", urldecode($page), $foo); //loop through all the variables on the page foreach ( $foo[1] as $key => $value ) { //debug output, you can delete this next line //echo "{$value} = {$foo[2][$key]}\t<br />\n"; //this chain of IF/elseif statements is used to determine which pattern to use //to strip out the correct data, since each sport seems to have its own format //for the variables you'd "want" if ( $sport == "NFL" && preg_match("/s_left\d+/", $value) ) { $results[$sport][] = $foo[2][$key]; } } } //calculate the sport with the most number of rows $limit = 0; foreach ( $results as $countMe ) { $limit = max($limit, count($countMe)); } //spit out the table with the right headers echo "<td><b> $title </b></td><br><BR>"; "<table border=4 cellpadding=10><tr><th>" . implode("</th><th>", array_keys($sports)). "</th></tr>" ; //loop until you reach the max number of rows, printing out all the table rows you want for ( $p = 0; $p < $limit; $p++ ) { foreach ( array_keys($sports) as $sport );{ $change = str_replace('^','<font color=green><b>W</b> </font>' ,$results[$sport][$p]); $final = str_replace('(FINAL)','<font color=red>(FINAL)', $change); echo "<td><font color=$fonts size=$fontc><b>$final</b></font></td><br>"; } echo "</tr>"; } //kill the table echo "</table>"; and it works fantastically well however.... I'd only like to get certain data say like the Cowboys game info and nothing more... NOT too sure how to do this, I'm just not really sure how to read the page, grab only that data. Help would be greatly appreciated! Thank you. |