PHP - Mailing Form
First off, hello.
This is my first pHp code, and still tying to get a grasp on it all. This is the pHp i have for my mailing form. Now i wish to make the user have to put in a valid email address. Except it isn't working for me. The following script isn't coming up with any errors, but it is still letting the email field be submitted with any text. <?php if ($_POST['submit']) { $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; $errorstring = ""; if (!$name) $errorstring = $errorstring."Name<br>"; if (!$email) $errorstring = $errorstring."email<br>"; if (!$comments) $errorstring = $errorstring."comments<br>"; if ($errorstring!="") echo "You missed the following:<br>$errorstring"; else { $webMaster = "name@site.com"; $emailSubject = "Contact Us Form"; $mail_from = "$email"; $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; function valid_email($email) { if(eregi("^[\w\-]+?\@\w+?\.\w+$", $email)) { return TRUE; } else { return FALSE; } } if (!valid_email($email)) { die('bad email'); } $body = ' <br> Name ' . $name . ' <br><br> ' . $email . ' <br><hr><br> Comments<p> ' . $comments . ' '; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); $redirect = file_get_contents('redirect.html'); echo $redirect; } } ?> Thank you. Similar TutorialsHey everyone I'm pretty new at PHP so i'm hoping someone can help me with this code. What I am trying to do is if someone selects a state say Kansas then fills out the rest of the form and clicks submit it will go to a specific email address. If someone selects another state like Nebraska it will go to a separate email address. Here is my code and I hope someone can help me with this. PS I think I really screwed this one up lol :help: Thanks, B Code: [Select] <?php /* Subject and Email variables */ $emailSubject = 'Your Car Report Info.'; $webMaster = 'me@rustyeckford.com'; $webMaster2 ='me1@rustyeckford.com'; $webMaster3 ='me2@rustyeckford.com'; /* Gathering Data Variables */ $f_nameField = $_POST['f_name']; $l_nameField = $_POST['l_name']; $addField = $_POST['Address']; $stateField = $_POST['state']; $phoneField = $_POST['phone']; $emailField = $_POST['email']; $vinField = $_POST['vin']; $body = <<<EOD <br><hr><br> First Name: $f_name <br> Last Name: $l_name <br> Address: $Address <br> State: $state <br> Phone: $phone <br> Email: $email <br> VIN: $vin <br> EOD; switch($state) { case 'Kansas': case 'Oklahoma': $wm = $webMaster2; break; case 'Missouri': case 'Iowa': $wm = $webMaster3; break' case 'Nebraska: $wm = $webMaster; break; } $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($wm, $emailSubject, $body, $headers); /* Results rendered from Html */ $theResults = <<<EOD <html> <head> <title>Your Car Report - Results</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } </style> </head> <div> <div align="center">Thank you for your submission. Your vehicle report will be provided to you very soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> Hey, been trying to make a form to upload an image to the server and also email the image as attachment. After nearly a week I managed to make it work. Only some validation needs to be done. My next step is to make it work for multiple files, ie. 5. The form will have 5 boxes to upload images and no more. I have tried a few different things with for loops ( ie for $i=0; $i<5; $i++ {...} ) but no luck. I can't think of any solution of a loop to upload multiple files and then email multiple attachment as my code. The code is: <?php session_start(); $imagename1 = $_FILES["uploadFile1"]["name"]; $_SESSION['imagename1'] = $imagename1; $imagename1 = $_SESSION['imagename1']; $imagetype1 = $_SESSION['imagetype1']; $imagesize1 = $_SESSION['imagesize1']; $imagetemp1 = $_SESSION['imagetemp1']; $thankyouurl = 'thankyou.php' ; $errorurl = 'error.php' ; $http_referrer = getenv( "HTTP_REFERER" ); $http_agent = getenv( "HTTP_USER_AGENT" ); $domain = $_SERVER['REMOTE_ADDR']; $filename = $_SESSION['uploadFilename']; if(isset($_POST['send'])) { $fp = fopen($imagetemp1, "rb"); $file = fread($fp, $imagesize1); $file = chunk_split(base64_encode($file)); $num = md5(time()); fclose($fp); // UPLOAD FILE // possible PHP upload errors $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); // check the upload form was actually submitted else print form isset($_POST['send']) or error('the upload form is neaded', $uploadForm); // check for standard uploading errors ($_FILES[$fieldname1]['error'] == 0) or error($errors[$_FILES[$fieldname1]['error']], $uploadForm); // check that the file we are working on really was an HTTP upload @is_uploaded_file($_FILES[$fieldname1]['tmp_name']) or error('not an HTTP upload', $uploadForm); // validation... since this is an image upload script we // should run a check to make sure the upload is an image @getimagesize($_FILES[$fieldname1]['tmp_name']) or error('only image uploads are allowed', $uploadForm); // make a unique filename for the uploaded file and check it is // not taken... if it is keep trying until we find a vacant one $now = date("y-m-d_H-i-s", time()); while(file_exists($uploadFilename = $uploadsDirectory.$now.'_'.$_FILES[$fieldname1]['name'])) { $now++; } // now let's move the file to its final and allocate it with the new filename @move_uploaded_file($_FILES[$fieldname1]['tmp_name'] , $uploadFilename) or error('receiving directory insuffiecient permission', $uploadForm); $from= 'youremail@server.co.uk'; $emailTo = 'mail@hotmail.com'; $subject = 'Quote Form'; $body = "equipment_type: $equipment_type \n\nModel: $Model \n\nMake: $Make \n\nModelNumber: $ModelNumber"; $fp = $_SESSION['fp']; $file = $_SESSION['file']; $num = "==Multipart_Boundary_x{$semi_rand}x".$_SESSION['num']; $headers = 'From: Name <'.$from.'>' . "\r\n" . 'Reply-To: ' . $emailTo; //Normal headers $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$body."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$imagetype1." "; $headers .= "name=\"".$imagename1."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$imagename1."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; mail($emailTo, $subject, $body, $headers); header( "Location: $thankyouurl" ); } ?> the form is like this Code: [Select] <input name="uploadFile1" id="uploadFile1" value="" class="file" type="file"/>can anyone suggest anything please? how can I form the for statement? much appreciated Hi all, I have a problem with emailing php code using a php function. using the code below, It emails the message 2 times with blank content. I think the problem might be with the eval() or file_get_content(), because if I comment it out the eval() and replace $message with a static value, it sends the message once with the static content. The functions safeText (which does a mysql_real_escape_string), returnShopName (which returns the shop name) and returnShopEmailURL(which returns the url of the shop minus the http://www) all work, as they are used in other functions. here is the function: Code: [Select] <?php //Email a link to the voucher function emailVoucher($id) { //Ensure no one can use a combined URL and SQL Injection attack, as it comes from a $_GET $id = safeText($id); //Query the database, count the results and make an array to hold them $query = mysql_query("SELECT * FROM shop_vouchers WHERE voucher_id = '".$id."' LIMIT 1") or die ('Error: '.mysql_error()); $count = mysql_num_rows($query); $fetch = mysql_fetch_array($query); //If there are results if($count == 1) { $to = $fetch["voucher_email"]; $subject = 'Your voucher from '.returnShopName(); $headers = 'From: website@'. returnShopEmailURL() . "\r\n" . 'Reply-To: no-reply@'. returnShopEmailURL() . "\r\n" . 'X-Mailer: PHP/' . phpversion() . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html' . "\r\n"; $link = 'http://www.example.com/vouchers.php?email=1'; $name = returnShopName(); $URL = returnShopEmailURL(); $body = file_get_contents('includes/voucher_email.php'); eval("\$body = \"$message\";"); mail($to, $subject, $message, $headers); gotoURL("vouchers.php?issue=1"); }else{ //Popup error message and redirect echo '<script type="text/javascript">'; echo 'alert("An error occurred. Please try again.")'; echo '</script>'; gotoURL("vouchers.php"); } } ?> the code in voucher_email.php (for testing purposes) is: Code: [Select] $name 1, $link 2, $URL 3 I have email's in mysql... how do i automatically send emails every week. I know how to send mail with php. How do i automatically send it every week? I have a mail list script, problem is if I have to many mails sent at one time my website will be suspended. What should I do? I'm trying to send an email that has a list created from a while loop to multiple people with an email list created from while loop. Can someone please help me figure this out? My brain is fried. Here's the code that I have: This is producing an error message that reads: Parse error: syntax error, unexpected '{' in /home/content/29/6879529/html/calhoun/admin/sendreport.php on line 22 Code: [Select] <?php include("conf.inc.php"); $result = mysql_query("SELECT `prefix`,`lname`,`email` FROM admin"); $row = mysql_fetch_row($result); $result2 = mysql_query("SELECT `to`,`from`,`subject`,`message`,`date` FROM allmsgs WHERE reported = 'n' ORDER BY `messid` ASC"); $row2 = mysql_fetch_row($result2); $cdate = date('m-d-Y'); while ($row = mysql_fetch_row($result)) { $prefix = $row[0]; $lname = $row[1]; $adminemail = $row[2]; $fullname = "$prefix $lname"; $sendto = "$adminemail"; $emailsubject = "Webstats Report For $cdate."; while ($row2 = mysql_fetch_row($result2){ // This is line 22. $to = $row2[0]; $from = $row[1]; $subject = $row[2]; $message = $row[3]; $datetime = $row[4]; $eachmessage = "<p> <hr width=\"400\"> To: $to<br> From: $from<br> On $datetime<br> <br> $subject<br>$nbsp;<br> $message </p>"; } $emailmessage = "<html> <body> $fullname, <p> Here is a list of the messages that have been exchanged in the last 24 hours.</p> $eachmessage </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Webstats <reports@webstats.com>' . "\r\n"; // Mail it mail($sendto, $emailsubject, $emailmessage, $headers); } ?> Hello, I know very little about PHP, i am a graphics and HTML guy , i had a simple mailing list script up on a clients page for a couple years, and now all of a sudden it has stopped working. When you enter your name, and email, you get "select fails" and it does not get added to the database. Here is the code, any help would be great, i am lost since nothign has changed, but it just stoppped working. from the config.php file Code: [Select] function insert_mail() { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $sql2="select * from mail where email='$email'"; $result2=mysql_query($sql2) or die("select fails"); $no=mysql_num_rows($result2); if ($no==0) { $sql = "insert into mail(id,fname,lname,email) values(NULL,'$fname','$lname','$email')"; $result = mysql_query($sql) or die("insert fails"); echo "Email added to list: " . LISTNAME; } else { echo "Email Address Already Exists in List: " . LISTNAME; } } function delete_mail() { $email = $_POST['email']; if ($email == "") { $email = $_GET['email']; } $sql2="select * from mail where email='$email'"; $result2=mysql_query($sql2) or die("select fails"); $no=mysql_num_rows($result2); if ($no==0) { echo "Your email was not found in the list: " . LISTNAME; } else { echo "Your email was unsubscribed from the list: " . LISTNAME; } $sql2="delete from mail where email='$email'"; $result2=mysql_query($sql2) or die("unsubscribe failed, please try again"); } ?> From the HTML Code: [Select] <center> <form action='<? echo BASEHREF; ?>index.php' method=post> <TABLE BORDER=0 ALIGN=center> <TR> <TD><b>first name</b></TD> <TD><INPUT TYPE=text name=fname></TD> </TR> <TR> <TD><b>last name</b></TD> <TD><INPUT TYPE=text name=lname></TD> </TR> <TR> <TD><b>email</b></tD> <TD><INPUT TYPE=text name=email></td> </tR> <TR> <TD colspan=2 align=center><INPUT TYPE=submit value=join> <INPUT TYPE=reset value=reset><BR></TD> </tR> </TABLE> </FORM> </center> Let me know what else you may need.... I'm using 3 files to try and mass mail my members, massmail.php massmail-exe.php and elist.php massmail.php <form name="massmail" method="post" action="./massmail-exe.php"> <table width="450px"> <tr> <td valign="top"> <label for="subject">Subject</label> </td> <td valign="top"> <input type="text" name="subject" maxlength="50" size="30" id="subject"> </td> </tr> <tr> <td valign="top"> <label for="message">Email Content</label> </td> <td valign="top"> <textarea name="message" maxlength="9001" cols="100" rows="18" id="message"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> </td> </tr> </table> </form> massmail-exe.php <?php // read the list of emails from the file. $email_list = file("./elist.php"); // count how many emails there are. $total_emails = count($email_list); // go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } // implode the list into a single variable, put commas in, apply as $to value. $to = implode(",",$email_list); if ( mail($to,$_POST["subject"],$_POST["message"]) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> and elist.php which has the email addresses. What is wrong because every time i try and send it it say query failed. Thanks so much. Hi, I am new to this forum and hopefully u guys can help me solve the problem i have in this first post! So please take a look at this html script <html> <head> <title>Sub/Unsub</title> </head> <body> <h1> Subscribe or unsubscribe mailing list</h1> <form method=POST action="manage.php"> <p><b>Your E-mail address:</b></br> <input type=text name="email" size=40 maxlength=150> <p><b>Action:</b></p> <input type=radio name="action" value="sub" checked>Subscrbie <input type=radio name="action" value="unsub">Unsubscribe <p><input type=submit name="submit" value="Submit form"></p> </form> </body> </html> And this is the manage.php script: <?php //set up a couple of functions include('connect.php'); function emailChecker($email){ global $connect, $check_result; //check mail is not already in list $check = "select id from users where email = '$email'"; $check_result = mysqli_query($connect, $check) or die(mysqli_error($connect)); } if ( ($_POST[action] == 'sub')){ //Try to subscribe, so validate email if($_POST[email]=""){ hearder("Location: manage_start.php"); exit(); } //connect to database db(); //check if email is on the list emailChecker($_POST[email]); //check the number of results to look for duplicates if (mysqli_num_rows($check_result)<1){ //since no records detected, so add this new email $sql="INSERT into users (email) values('$_POST[email]')"; $result = mysqli_query($connect, $sql) or die(mysqli_error($connect)); echo "<p>Thanks for signing up man!!</p>"; } else { //print failure message echo "<p>You have already subscribed!</p>"; } } else if (($_POST[action] == "unsub")){ //trying to unsubscribe and validate address if ($_POST[email] == "") { header ("Location: manage_start.html"); exit(); } db(); emailChecker($_POST[email]); if (mysqli_num_rows($check_result) <1) { //print failure message echo "<p>Cannot find your address!</p> <p>No action is taken</p>"; } else { //unsubscribe address $id = mysqli_real_escape_string($connect, $_POST['id']); $sql = "DELETE from users where id = '$id'"; $result = mysqli_query($connect, $sql) or die(mysqli_error()); echo "<p>You have unsubscribed!</p>"; } } ?> So wut i am trying to do in this script is to create a mailing list form for user to subscribe/unsubscribe using email address. When i first run the html script (which includes php script) and subscribe by the first time, it went perfectly fine and it echos "thanks for signing up man!!" but when i try it with the totally DIFFERENT email address, it always says "You have already subscribed!!" Even when i put blank on the address box, it still shows "You have already subscribed!!" Also it's the same deal as unsubscribe, first time i could delete an entry from my database completely, but afterward when i try to delete the exact email addresses from database, it wouldn't work !! It just says "You have unsubscribed!" but when i checked back if the entry has been deleted, the answer is NO ! I am wondering if this is the problem about $global values under function emailChecker( ). Btw my database connection works absolutely fine. I know this is a long ass post but i need an urgent answer PLZZZZZZZZ Hi guys, I was just wondering if anyone could help me. I've got a My_SQL database containing articles, a summary for the article and a date. I have a basic CMS system set-up, but I want to create a script that when users sign up to a mail list it forwards the summary and dates of the articles database. If that makes sense? But I only want it to forward the most recent 5 rows. I'm pretty new to PHP and I've been mostly following tutorials thus far, but this is quite specific. Thanks in advance! Hi, PHP beginner here.
I'm trying to run a very basic script which does the following:
1) Input some data into a form
2) Outputs the data onto the screen
3) Click submit and e-mail it to me.
The purpose of it is simply to learn how to input some data, output that data along with some basic calculations and then to send that data to an e-mail address.
#1 & #2 I can do. I can enter some text and some numbers and on the next screen I can print a message containing the data I put into the form.
Also I am taking the variables and doing some calculations which is fine.
However, when I click submit (on the second screen) to e-mail the data to me, I am getting an e-mail but none of the variables have retained the data.
FORM
<html> <?php //Database Credentials include "../db_fns.php"; session_start(); //Database connection $conn = db_connect_2(); if (isset($_SESSION['link']) AND !isset($_POST['Submit'])){ //retrieve link if(is_string($_SESSION['link'])){ $link = unserialize($_SESSION['link']); } else { $link = $_SESSION['link']; } if($link){ //basic stuff $_SESSION['transgene_type'] = (string)$link->tt_id; $_SESSION['promoter_locus'] = $link->promoter; $_SESSION['PromoLocusSynonyms'] = $link->pl_synonyms; $_SESSION['species'] = (string)$link->s_id; //genetic background //clear it just incase there are values since another time $_SESSION['genetic_bg'] = array(); $_SESSION['GeneticBGOtherTxt'] = ""; foreach($link->genetic_bg as $gbg){ //we check if it is a menu selected item or an item that is not in menu if((int)$gbg['GBG_IS_MENU']){ $_SESSION['genetic_bg'][] = $gbg['GBG_ID']; } else { //belongs in other if(empty($_SESSION['GeneticBGOtherTxt'])) { $_SESSION['GeneticBGOtherTxt'] .= $gbg['GBG_NAME']; } else { $_SESSION['GeneticBGOtherTxt'] .= ",".$gbg['GBG_NAME']; } } } $_POST = $_SESSION; }elseif (isset($_POST['Submit'])) { if(isset($_SESSION['link'])) { //we need to unserialize the link if(is_string($_SESSION['link'])){ $link = unserialize($_SESSION['link']); //unserialize() takes a single variable and converts it back into a php value } else { $link = $_SESSION['link']; } } //put $_POST variables into $_SESSION $_SESSION = $_POST + $_SESSION; unset($_SESSION['Submit']); // CHECK FOR ERRORS AFTER SUBMISSION $errors = array(); // Set array if (!$_POST['promoter_locus']) $errors[] = "Please specify a value for \"Promoter or Locus\"".$PromoLocus; if (!$_POST['transgene_type']) $errors[] = "Please specify a value for \"Transgene Type\""; if (!$_POST['inducible_systems'] && !$_POST['InducibleSystemsOther']) $errors[] = "Please specify an \"Inducibility\" value"; } if (count($errors) > 0 ) { $iferrors = "Yes"; } else { [SIZE="4"][B][U] include ('mailing_list.php'); checkPromoter($_POST['promoter_locus'];[/U][/B][/SIZE] //this is to check that step one has been completed once we go to step 2 $_SESSION['step'] = 2; header("Location: StepTwo_2.php"); exit; } } } else { session_trash_(); session_regenerate_id(true); } Note that this script is an excerpt and I make the lines that I put to be bold and underlined. This is the mailing_list.php <?php require('connection.php'); function checkPromoter ($_POST['promoter_locus']) { $check = "select id from mailing_list where query = '$_POST['promoter_locus']'"; $result = mysqli_query($connect, $check) or die(mysqli_error($connect)); if (mysqli_num_rows($result)==0){ continue; } else { $sql = "select email from mailing_list where query = '$_POST['promoter_locus']'"; $query = $_POST['promoter_locus']; $email = mysqli_query($connect, $sql) or die(mysqli_erro($connect)); $to = $email; $subject = "The query is updated"; $headers = "From: asdfasdf"; $body = " Hello This is to inform you that $query is updated, please go to this link to search for it: http://asdfasdf Regards, asdfasdf."; mail($to, $subject, $body, $headers); die(); } } So my questions are 1. Where should I place those bold lines in addEntry.php? I tried to run it but the result is a blank page... Also there's no email sending through to my test email 2. For the line function checkPromoter ($_POST['promoter_locus']), should I put variable like $promoter = $_POST['promoter_locus'] ? Cuz I ran that and the error is Parse error: syntax error, unexpected '[', expecting ')' 3. Can u guys please help me fix up mailing_list.php? thanks for ur patience to read thru this and ANY HELP IS APPCRECIATED :p Somebody please tell me why this wont work. Didnt wont to put my email in their. <?php $user = $_POST['subject']; $email = $_POST['email']; $message = $_POST['message']; //To, Subject, Message mailto(''); mailsubject('$user Sent you a message'); mailfrom('From: ' . $user . ' <' . $email . '>'); ?> Hi I have been given a task to create some SQL reports. One of the reports is to display all the customers who have purchased a certain product based on user selection and then have those results able to be extracted to a mailing list. So ive got the report done. Some drop down boxes allow a user to select a product and once submitted the results are then displayed. But i dont even know where to begin with extracting those results to a mailing list. Could someone help me please? What method should I use? and where do i begin? BTW im a rookie with PHP/Mysql ive just got my first job since leaving university and this is a task ive been given at work so any quick and helpful replies are greatly appreciated Thanks in advance. what I am trying to do is use this php script to load the data being submitted in the html form into my database and then populate the database into an excel (xls) file and then e-mail it to my address. Everything works great it populates into the database and creates the xls file perfect. But it is wanting me to download the file. What can I add to the script to have it e-mail the file to my e-mail address INSTEAD of downloading it. Code: [Select] <?php define('DB_NAME', 'database'); define('DB_USER', 'username'); define('DB_PASSWORD', 'password'); define('DB_HOST', 'hostname'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die('Can\'t use ' . DB_NAME . ': ' . mysql_error()); } $value1 = $_POST['groupname']; $value2 = $_POST['name']; $value3 = $_POST['address']; $value4 = $_POST['city']; $value5 = $_POST['state']; $value6 = $_POST['zip']; $value7 = $_POST['homephone']; $value8 = $_POST['cellphone']; $value9 = $_POST['email']; $value10 = $_POST['age']; $value11 = $_POST['maritalstatus']; $value12 = $_POST['income']; $value13 = $_POST['contact1']; $value14 = $_POST['contact2']; $value15 = $_POST['contact3']; $value16 = $_POST['date1']; $value17 = $_POST['date2']; $value18 = $_POST['date3']; $sql = "INSERT INTO clients (groupname, name, address, city, state, zip, homephone, cellphone, email, age, maritalstatus, income, contact1, contact2, contact3, date1, date2, date3) VALUES ('$value1', '$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8', '$value9', '$value10', '$value11', '$value12', '$value13', '$value14', '$value15', '$value16', '$value17', '$value18')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close(); mysql_connect('hostname', 'username', 'password'); mysql_select_db('database'); $sql = "SELECT `groupname` AS `Group`, `name` AS `Customer Name`, `address` AS `Address`, `city` AS `City`, `state` AS `State`, `zip` AS `Zip Code`, `homephone` AS `Home Phone`, `cellphone` AS `Cell Phone`, `email` AS `E-Mail`, `age` AS `Age Group`, `maritalstatus` AS `Marital Status`, `income` AS `Household Income`, `contact1` AS `Contact VIA`, `contact2` AS `Contact VIA`, `contact3` AS `Contact VIA`, `date1` AS `1st Date`, `date2` AS `2nd Date`, `date3` AS `3rd Date` FROM fundtour_info.clients clients"; // Query Database $result=mysql_query($sql); $filename = 'file.xls'; // Send Header header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download");; header("Content-Disposition: attachment;filename=$filename"); header("Content-Transfer-Encoding: binary "); // XLS Data Cell xlsBOF(); xlsWriteLabel(0,0,"Group"); xlsWriteLabel(0,1,"Name"); xlsWriteLabel(0,2,"Address"); xlsWriteLabel(0,3,"City"); xlsWriteLabel(0,4,"State"); xlsWriteLabel(0,5,"Zip Code"); xlsWriteLabel(0,6,"Home Phone"); xlsWriteLabel(0,7,"Cell Phone"); xlsWriteLabel(0,8,"E-mail Address :"); xlsWriteLabel(0,9,"Age Group"); xlsWriteLabel(0,10,"Marital Status"); xlsWriteLabel(0,11,"Income"); xlsWriteLabel(0,12,"Contact Via"); xlsWriteLabel(0,13,"Dates"); $xlsRow = 1; while(list($groupname,$name,$address,$city,$state,$zip,$homephone,$cellphone,$email,$age,$maritalstatus,$income,$contact1, $contact2, $contact3,$date1, $date3, $date3)=mysql_fetch_row($result)) { ++$i; xlsWriteLabel($xlsRow,0,"$groupname"); xlsWriteLabel($xlsRow,1,"$name"); xlsWriteLabel($xlsRow,2,"$address"); xlsWriteLabel($xlsRow,3,"$city"); xlsWriteLabel($xlsRow,4,"$state"); xlsWriteLabel($xlsRow,5,"$zip"); xlsWriteLabel($xlsRow,6,"$homephone"); xlsWriteLabel($xlsRow,7,"$cellphone"); xlsWriteLabel($xlsRow,8,"$email"); xlsWriteLabel($xlsRow,9,"$age"); xlsWriteLabel($xlsRow,10,"$maritalstatus"); xlsWriteLabel($xlsRow,11,"$income"); xlsWriteLabel($xlsRow,12,"$contact1, $contact2, $contact3"); xlsWriteLabel($xlsRow,13,"$date1, $date3, $date3"); $xlsRow+++; } xlsEOF(); exit(); function xlsBOF() { echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); return; } function xlsEOF() { echo pack("ss", 0x0A, 0x00); return; } function xlsWriteNumber($Row, $Col, $Value) { echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); echo pack("d", $Value); return; } function xlsWriteLabel($Row, $Col, $Value ) { $L = strlen($Value); echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); echo $Value; return; } ?> Thanks for any help Hello, I have coded a contact form in PHP and I want to know, if according to you, it is secure! I am new in PHP, so I want some feedback from you. Moreover, I have also two problems based on the contact form. It is a bit complicated to explain, thus, I will break each of my problem one by one. FIRST:The first thing I want to know, is if my contact form secure according to you: The HTML with the PHP codes: Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Assigning variables to elements $first = htmlentities($_POST['first']); $last = htmlentities($_POST['last']); $sub = htmlentities($_POST['subject']); $email = htmlentities($_POST['email']); $web = htmlentities($_POST['website']); $heard = htmlentities($_POST['heard']); $comment = htmlentities($_POST['message']); $cap = htmlentities($_POST['captcha']); //Declaring the email address with body content $to = 'alithebestofall2010@gmail.com'; $body ="First name: '$first' \n\n Last name: '$last' \n\n Subject: '$sub' \n\n Email: '$email' \n\n Website: '$web' \n\n Heard from us: '$heard' \n\n Comments: '$comment'"; //Validate the forms if (empty($first) || empty($last) || empty($sub) || empty($email) || empty($comment) || empty($cap)) { echo '<p class="error">Required fields must be filled!</p>'; header ('refresh= 3; url= index.php'); return false; } elseif (filter_var($first, FILTER_VALIDATE_INT) || filter_var($last, FILTER_VALIDATE_INT)) { echo '<p class="error">You cannot enter a number as either the first or last name!</p>'; return false; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<p class="error">Incorrect email address!</p>'; return false; } elseif (!($cap === '12')){ echo '<p class="error">Invalid captcha, try again!</p>'; return false; } else { mail ($to, $sub, $body); echo '<p class="success">Thank you for contacting us!</p>'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Your first name: <span class="required">*</span></p> <p><input type="text" name="first" size="40" placeholder="Ex: Paul"/></p> <p>Your last name: <span class="required">*</span></p> <p><input type="text" name="last" size="40" placeholder="Ex: Smith"/></p> <p>Subject: <span class="required">*</span></p> <p><input type="text" name="subject" size="40" placeholder="Ex: Contact"/></p> <p>Your email address: <span class="required">*</span></p> <p><input type="text" name="email" size="40" placeholder="Ex: example@xxx.com"/></p> <p>Website:</p> <p><input type="text" name="website" size="40" placeholder="Ex: http//:google.com"/></p> <p>Where you have heard us?: <span class="required">*</span></p> <p><select name="heard"> <option>Internet</option> <option>Newspapers</option> <option>Friends or relatives</option> <option>Others</option> </select></p> <p>Your message: <span class="required">*</span></p> <p><textarea cols="75" rows="20" name="message"></textarea></p> <p>Are you human? Sum this please: 5 + 7 = ?: <span class="required">*</span></p></p> <p><input type="text" name="captcha" size="10"/></p> <p><input type="submit" name="submit" value="Send" class="button"/> <input type="reset" value="Reset" class="button"/></p> </form> SECOND PROBLEM:If a user has made a mistake, he gets the error message so that he can correct! However, when a mistake in the form occurs, all the data the user has entered are disappeared! I want the data to keep appearing so that the user does not start over again to fill the form. THIRD: When the erro message is displayed to notify the user that he made a mistake when submitting the form, the message is displaying on the top of the page. I want it to appear below each respective field. How to do that? In JQuery it is simple, but in PHP, I am confusing! I 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'] ?> Stumped! I have a client who has a form where they upload files to their server: title, two password fields, and the file
They have been unable to upload anything over 10m
Small (under 10mb) files work.
Larger doesn’t
I’ve tracked it down, I think, that the processing page appears to be dropping the form values when the file takes a bit to upload.
I echo’ed the values that are grabbed from the form, and they return empty strings if it takes a while for the file to upload (a large file) - they pass fine if the file is smaller.
I think I've got the php info set correctly, but cannot for the life of me figure out how to adjust the timing out issue, or even where to troubleshoot.
Here's my phpinfo:
Max Requests
Per Child: 750 - Keep Alive: off - Max Per Connection: 100
Timeouts
Connection: 120 - Keep-Alive: 5
Directive
Local Value
Master Value
allow_call_time_pass_reference
Off
Off
allow_url_fopen
On
On
allow_url_include
Off
Off
always_populate_raw_post_data
Off
Off
arg_separator.input
&
&
arg_separator.output
&
&
asp_tags
Off
Off
auto_append_file
no value
no value
auto_globals_jit
On
On
auto_prepend_file
no value
no value
browscap
/etc/browscap.ini
/etc/browscap.ini
default_charset
no value
no value
default_mimetype
text/html
text/html
define_syslog_variables
Off
Off
disable_classes
no value
no value
disable_functions
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
display_errors
Off
Off
display_startup_errors
Off
Off
doc_root
no value
no value
docref_ext
no value
no value
docref_root
no value
no value
enable_dl
Off
Off
error_append_string
no value
no value
error_log
/mnt/Target01/337846/945285/www.dermerrealestate.com/logs/php_errors.log
no value
error_prepend_string
no value
no value
error_reporting
30711
30711
exit_on_timeout
Off
Off
expose_php
Off
Off
extension_dir
/usr/lib64/php/modules
/usr/lib64/php/modules
file_uploads
On
On
highlight.bg
#FFFFFF
#FFFFFF
highlight.comment
#FF8000
#FF8000
highlight.default
#0000BB
#0000BB
highlight.html
#000000
#000000
highlight.keyword
#007700
#007700
highlight.string
#DD0000
#DD0000
html_errors
On
On
ignore_repeated_errors
Off
Off
ignore_repeated_source
Off
Off
ignore_user_abort
Off
Off
implicit_flush
Off
Off
include_path
.:/usr/share/pear:/usr/share/php
.:/usr/share/pear:/usr/share/php
log_errors
On
On
log_errors_max_len
1024
1024
magic_quotes_gpc
On
On
magic_quotes_runtime
Off
Off
magic_quotes_sybase
Off
Off
mail.add_x_header
On
On
mail.force_extra_parameters
no value
no value
mail.log
no value
no value
max_execution_time
30
30
max_file_uploads
20
20
max_input_nesting_level
64
64
max_input_time
60
60
max_input_vars
1000
1000
memory_limit
128M
128M
open_basedir
no value
no value
output_buffering
no value
no value
output_handler
no value
no value
post_max_size
8M
8M
precision
14
14
realpath_cache_size
4M
4M
realpath_cache_ttl
120
120
register_argc_argv
On
On
register_globals
Off
Off
register_long_arrays
On
On
report_memleaks
On
On
report_zend_debug
On
On
request_order
no value
no value
safe_mode
Off
Off
safe_mode_exec_dir
no value
no value
safe_mode_gid
Off
Off
safe_mode_include_dir
no value
no value
sendmail_from
no value
no value
sendmail_path
/usr/sbin/sendmail -t -i
/usr/sbin/sendmail -t -i
serialize_precision
100
100
short_open_tag
On
On
SMTP
localhost
localhost
smtp_port
25
25
sql.safe_mode
Off
Off
track_errors
Off
Off
unserialize_callback_func
no value
no value
upload_max_filesize
8M
8M
upload_tmp_dir
/tmp
/tmp
user_dir
no value
no value
user_ini.cache_ttl
300
300
user_ini.filename
.user.ini
.user.ini
variables_order
EGPCS
EGPCS
xmlrpc_error_number
0
0
xmlrpc_errors
Off
Off
y2k_compliance
On
On
zend.enable_gc
On
On
Hello, first time poster.. I've looked the web over for a long time and can't figure this one out. - Below is basic code that successfully checks MySQL for a match and displays result. I was debugging and forced the "height" and "width" to be 24 and 36 to make sure that wasn't the problem. That's good.. - I'd like to give the user ability to select width and height from a form.. and have it do an onchange this.form.submit so the form can be changing as fields are altered (thus the onchange interaction) - In a normal coding environment I've done this numerous times with no "Page cannot be displayed" problems. It would simply change one select-option value at a time til they get down the form and click submit... but in WordPress I'm having trouble making even ONE single onchange work! - I've implemented the plugins they offer which allows you to "copy+paste" your php code directly into their wysiwyg editor. That works with basic tests like my first bullet point above. - I've copied and pasted the wordpress url (including the little ?page_id=123) into the form "action" url... that didn't work... tried forcing it into an <option value=""> tag.. didn't work. I'm just not sure. I've obviously put xx's in place of private info.. Why does this form give me Page Cannot Be Displayed in WordPress every time? It won't do anything no matter how simple.. using onchange.. Code.. $con = mysql_connect("xxxx.xxxxxxx.com","xxxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $myprodwidth=24; $myprodheight=36; $result = mysql_query("SELECT * FROM product_sizes WHERE prodwidth='$myprodwidth' and prodheight='$myprodheight'"); while($row = mysql_fetch_array($result)) { echo $row['prodprice']; } mysql_close($con); <form method="post" action=""> <select name="myheight" onchange="this.form.submit();"> <option selected="selected" value="">select height</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">36</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">48</option> </select> |