PHP - Going Insane!!!! Need Simple Form Help.
I want to have a form with a drop down menu that decides who gets the email. But I ALSO want the email to go to me. Can anyone tell me the simplest way to go about this?
This is my form page: Code: [Select] <form method="post" action="sendorderform.php"> Email: <input name="email" type="text" /><br /> Message:<br /> <textarea name="message" rows="15" cols="40"> </textarea><br /> <select name='emailto' id='emailto'> <option value='me@yahoo.com'>man1@website.com</option> <option value='man2@website.com'>man2@website.com</option> <option value='man3@website.com'>man3@website.com</option> <option value='man4@website.com'>man4@website.com</option> </select><br> <input type="submit" /> </form> This is my php page: Code: [Select] <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $email_to = $_POST['emailto'] ; mail( $email_to, "Feedback Form Results", $message, "From: $email" ); ?> I actually got this to send per the drop down. But, where do I put MY (fixed) email address to make it send TWO emails? Thanks for any help!!! I'm very new at this stuff. Similar TutorialsHi guys, I am going nuts with this! It HAS to be something dead simple but I can't seem to see what is staring me in the face. Basically I have made a registration form and when complete you are emailed a link to click on. When you click on the link you go to a new page. The page takes the email address and the verification code from the URL via _GET. The database is then queried for a match of the email address AND the verification code, if there is a relevant record then success is displayed otherwise unsuccessful is displayed. Code: Code: [Select] $email = strip_tags(htmlentities($_GET['email'])); $code = strip_tags(htmlentities($_GET['code'])); // confirm the variables hold the correct data echo "email: $email and code: $code"; $query = "SELECT * from userdb WHERE email='$email' AND code ='$code'"; if (mysql_query($query)) { echo "success"; } else { echo "unsuccessful"; } My problem is this query is always returning 'success'... even when the code and/or email does not match what is in my database? What am i missing? Thanks first i have a standard html page. Just a form that submits data to upload.php http://pixel.imgboard.co.uk here is upload.php - note i know i have some weird echo's but ive been trying for 2 hours to get upload.php to display something... but nothing happens.. i cant even get it to output html. It just goes to upload.php and has a blank page. When i view source there is nothing there. Its literally a blank page. I can't work it out. someone please help. I'm going to crack up. <?php ini_set("display_errors", "1"); error_reporting(E_ALL); session_start(); include 'http://www.imgboard.co.uk/includes/functions.php'; $start = " <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> <link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.imgboard.co.uk/style/pixel.css\" /> <title> Pixel - Image Hosting Beta</title> </head> <body> <div id =\"wrapper\"> <div class = 'titlebar'> <div class = 'titlebarlinkbox'> <a href = 'http://www.imgboard.co.uk'>Forum</a> <a href = 'http://www.imgboard.co.uk/Wiki.php'>Wikis</a> <a href = 'http://www.imgboard.co.uk/bulletins/0'>Bulletins</a> <a href = 'http://www.imgboard.co.uk/faq/0'>Faq's</a> </div> </div> <div class = \"logo\"></div> "; $end = " <div class = 'footerLinks'> Pixel @ 2010 - 2015 ! <br /> <a href = 'http://www.imgboard.co.uk'>Forum</a> | <a href = 'http://www.imgboard.co.uk/Wiki.php'>Wikis</a> | <a href = 'http://www.imgboard.co.uk/bulletins/0'>Bulletins</a> | <a href = 'http://www.imgboard.co.uk/faq/0'>Faq's</a> | <a href = 'http://www.imgboard.co.uk/pixel/report.php'>Report Image</a> </div> <div class = 'TnC'>Pixel is a Trademark of imgboard.co.uk. Please ensure all content uploaded is decent. No Taboo, cp, gore allowed. Porn / memes / misc themes all welcome. Any offensive content will be removed and deleted. Any misuse of the service and result in banning and in seviere cases prosecution.</div> </div> </body> </html> "; if(isset($_GET['uploadfile'])){ echo $start; echo $end; $validExtensions = array("png", "gif", "jpeg", "jpg", "bmp"); $ext = end(explode(".",$_FILES["image"]["name"])); $ext2= strtolower($ext); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/bmp") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 10000000)) && in_array($ext2,$validExtensions)) { //create a unique name. $newname = date(dmYhis); $newname .= rand(1111,9999); //preg replace non alpha numeric characters $fname = $_FILES['file']['name']; $newname = $newname . "." .$ext2; $location = "http://www.imgboard.co.uk/images/".$newname; //copy the file. if(move_uploaded_file($_FILES['file']['tmp_name'],$location)){ //file uploaded create display Page. $t = $_POST['tags']; add_uploaded_image($location,$t); file_upload_display_page($location); } else{ die("Error Occured Moving File"); } } else{ die("wrong mime type"); } } function add_uploaded_image($link, $tags){ $c = protect($_COOKIE['supercookie']); $ip = $_SERVER['REMOTE_ADDR']; $t = protect($tags); mysql_query("INSERT INTO pixel (filename,tags,date,ip,cookie) VALUES ('$link','$t',NOW(),'$ip','$c')") or die(mysql_error()); } function file_upload_display_page($location){ echo " <table class = 'uploadTable' cellspacing = '0'> <tr> <td class = \"label\"> Image Uploaded: </td><td><img src = '$location' HEIGHT = '150'/> </td> </tr> <tr> <td class = \"label\"> Direct Link: </td><td><input type = 'text' name = 'file' id = 'file' value = '$location'/> </td> </tr> <tr> <td class = \"label\"> Html Code </td><td><input type = 'text' name = 'tags' value = \"<img src = '$location' ALT = 'Hosted On http://Pixel.imgboard.co.uk'/>\"/> </td> </tr> <tr> <td> <td class = \"label\"> BB Code: </td><td><input type = 'text' name = 'file' id = 'file' value = '[img]http://$location[/img]'/> </td> </td> </tr> </table> "; } This topic has been moved to PHP Regex, where it should have been posted in the first place. http://www.phpfreaks.com/forums/index.php?topic=355176.0 I'm writing a very simple clean login session as a demonstration to friends. I've been over this code a lot of times and can't fault it, but obviously I am wrong.. or maybe xampp is just having one of those days. Undefined Index: username on line 30, login.php all files involved are attached. Thanks in advance. Code: [Select] <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; if ($username&&$password) { $connect = mysql_connect("localhost","root","") or die("couldn't connect"); mysql_select_db("login") or die("couldn't find db"); $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { //login code while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } //check is pass & user match if ($username==$dbusername&&$password==$dbpassword) { echo "you're in click here to enter the <a href='member.php'>member page</a> haha"; $_SESSION['username']==$dbusername; } else echo "incorrect password"; } else die("that user doesn't exist"); } else die("failed to connect") ?> I don't know who did this or why this was implemented, but it was the worst decision PHP made as it causes nothing but problems. Not having to define variables was one of the reasons I liked PHP. This is just my opinion so no roasts. Question is, what is the proper way to do this so I don't get this message 'cause I am hit and miss, even when I think I have them defined this stupid message pops up. This is the 3rd line on the on script that is causing me grief at the moment: $submit = $populate = $record = $row[] = $hid = $uid = $asset_tag = $type = $manufacturer = $model = $serial_number = $status = $location = $firstname = $lastname = $go = ""; Not sure why I need to have $row[] as it is the result of a SELECT and values are being given to it. Also not sure why I need it for $submit or $_POST as they already have values when they are passed to this page, so how can they be undefined when they have values. Just not getting it. Any help with this would really be appreciated. Thanks On my website i have a form for customers to get in touch with me. This forum points to a php script to email me and tell them it has been submitted(via html). Here is the forum and the php script. Form from html file Code: [Select] <form id="supportform" name="Support Form" method="post" action="php/formemail.php"> <table width="100%" border="0"> <tr> <td width="22%">Name:</td> <td width="78%"><input type="text" name="name" id="name" /></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" id="email" /></td> </tr> <tr> <td>Company:</td> <td><input type="text" name="company" id="company" /></td> </tr> <tr> <td>Phone:</td> <td><input type="text" name="phone" id="phone" /></td> </tr> <tr> <td>Operating System:</td> <td><input type="text" name="os" id="os" /></td> </tr> <tr> <td>What Do You Need Help With?</td> <td><input type="text" name="problem" id="problem" /></td> </tr> <tr> <td>Additional Clarification:</td> <td><textarea name="additional" id="additional" cols="45" rows="3"></textarea></td> </tr> <tr> <td>Contact Preference:</td> <td><select name="preference" id="preference"> <option value="null">Please Select</option> <option value="phone">Phone</option> <option value="email">Email</option> </select></td> </tr> <tr> <td>How Did You Hear Of Us?</td> <td><select name="advert" id="advert"> <option value="null">Please Select</option> <option value="radio">Radio</option> <option value="newspaper">Newspaper</option> <option value="other">Other</option> </select></td> </tr> <tr> <td><input type="submit" name="Submit" id="submit" value="Submit" style="width:100px;height:30px" /> <input type="reset" name="reset" id="reset" value="Reset" style="width:62px;height:30px;" /></td> <td> </td> </tr> </table> </form> Here is php script Code: [Select] <?PHP /*Subject an email variables */ $emailSubject = 'PHP Email Script'; $webMaster = 'me@mysite;otherperson@gmail.com'; /* Gathering Data Variables */ $nameField = $_POST['name']; $emailField = $_POST['email']; $companyField = $_POST['company']; $phoneField = $_POST['phone']; $osField = $_POST['os']; $problemField = $_POST['problem']; $additionalField = $_POST['additional']; $preferenceField = $_POST['preference']; $advertField = $_POST['advert']; $body = <<<EOD <br><hr><br> Name: $nameField <br> Email: $emailField <br> Company: $companyField <br> Phone: $phoneField <br> OS: $osField <br> Problem: $problemField <br> Additional Info: $additionalField <br> Preference: $preferenceField <br> Advertising: $advertField <br> <br> Have a nice day! EOD; $headers = "From: $emailField\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Title</title> <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" /> <link href="css.css" rel="stylesheet" type="text/css"> <style type="text/css"> body { background-color: #FFF; } </style> </head> <body> <div class="header"><a href="#"><img src="" alt="" name="greenhead" width="100%" height="17" id="greenhead" style="background: #B1FB17; display:block;" /></a> <!-- end .header --></div> <div class="content"> <h1> </h1> <h1><img src="/images/logo2.jpg" width="194" height="152" align="middle"> Tech Suppport MT</h1> <h1 align="center">Success!</h1> <h2 align="center">Your information has been submitted to us.</h2> <p align="center"> </p> <p align="center"><a href="/index.html">index - Home</a></p> <p> </p> <p> </p> <p> </p> </div> <div class="footer"> <h4 align="center">footer</h4> <!-- end .footer --></div> <!-- end .container --> </body> </html> EOD; echo "$theResults"; ?> Everything works as it should except both people are getting two emails. One email with everything correct and the correct results. And another with all null values from an unknown sender. I should not be receiving one from an unknown sender with empty values. Thanks for any help. Hello, I am trying to make a page with a text box in where the user enters their post code and hits 'Submit' then it loads a new page with an embeded google maps map of that area. with the following code: <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=gym+**POSTCODE**&sll=37.0625,-95.677068&sspn=30.461748,86.572266&ie=UTF8&hq=gym&hnear=**POSTCODE**,+United+Kingdom&output=embed"></iframe><br /><small><a href="http://www.google.com/maps?f=q&source=embed&hl=en&geocode=&q=gym+**POSTCODE**&sll=37.0625,-95.677068&sspn=30.461748,86.572266&ie=UTF8&hq=gym&hnear=**POSTCODE**,+United+Kingdom" style="color:#0000FF;text-align:left">View Larger Map</a> I have typed **POSTCODE** where the user input needs to go.. Any ideas how this could be done? Thanks Hi guys I'm trying to modify the following script so that only registered users can post comments. Can you guys help please thanks? <?php require_once("admin_common.php"); session_start(); if(is_numeric($_REQUEST['id'])){ $imageid = $_REQUEST['id']; }else{ header("Location: http://mysite.net/"); } if($_POST['submit']){ if($_POST['username']==''){ $err = "You must log in."; }elseif($_POST['thecomment']==''){ $err = "You have to enter a comment."; }else{ $name = strip_tags($_POST['thename']); $themessage = strip_tags($_POST['thecomment']); $ezdb->get_results("INSERT INTO user_comments (id,date_added, posted_by, message, image_id) VALUE ('','".time()."','".$name."','".$themessage."','".$imageid."')"); $err = "Thank you for your comment."; } } if($err){ $err = '<span style="color:#FF0000;">'.$err.'</span>'; } /* Update table `iid_ip`. Between the dashed lines is the create statement used to create the image view count (iid_ip) table. ---------------------------------------- delimiter $$ CREATE TABLE `iid_ip` ( `iid` int(11) unsigned NOT NULL COMMENT 'Image id from where the count is the number of unique views.', `ip` varchar(15) NOT NULL COMMENT 'The ip of the visitor.', PRIMARY KEY (`iid`), KEY `ip` (`ip`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Table for view count of image using unique ip''s.'$$ ---------------------------------------- */// Escape variables that are used in the query. $_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $_iid = mysql_real_escape_string($imageid); // Count is 0 if ip has NOT seen the images, else count is 1 $_count = $ezdb->get_var("SELECT COUNT(*) FROM `iid_ip` WHERE `iid`='$_iid' AND `ip`='$_ip'"); if (!$_count) { // Insert the unique combination of image id and visitor ip in `iid_ip`. // Method doesn't exists! $ezdb->quick_insert('iid_ip', array('iid' => $_iid, 'ip' => $_ip)); $ezdb->get_results("INSERT INTO `iid_ip` (`iid`,`ip`) VALUES ('$_iid','$_ip')"); } // Get count of image views. $_views = $ezdb->get_var("SELECT COUNT(*) FROM `iid_ip` WHERE `iid`='$_iid'"); // And format, thousands seperator is a comma, no decimals. $_views = number_format($_views, 0, '', ','); ///////////////////////////// $page->addHTMLHead($scripthead); $d[] = "<div id='imagedetails'>"; $imgs = $ezdb->get_results("Select * From image_map Where id='".$imageid."'"); $name = $ezdb->get_var("Select name From `".$imgs[0]->obj_type."s` WHERE id ='".$imgs[0]->obj_id."'"); if($imgs[0]->obj_type=='comment') $pg='comm'; if($imgs[0]->obj_type=='image') $pg='img'; $d[] = "<a href='imagepage.php?".$pg."=".$imgs[0]->obj_id."' style='text-decoration:none;'>«".ucfirst($imgs[0]->obj_type)."s - $name</a><br /><br />"; // DEFINE SIMPLE GRID if ($imgs[0]->user_id != 0) { $theuser = $ezdb->get_var("SELECT username FROM users WHERE user_id='".$imgs[0]->user_id."'"); } else { $theuser = $imgs[0]->creator_name; } $d[]="<div style='float:left; width:450px; text-align:center;'> <a href='contact.php'><img src='assets/images/leftAdjpg'></a> <br /> <div style='font-size:12px; margin-top:30px; margin-left:5px;'> ".'Html Code: Use for websites, blogs, profiles and myspace.<br /><input name="textfield3" type="text" class="imagedetails_links" id="textfield3" onclick="this.select();this.focus()" value="<a href="http://www.mysite.net/imagedetails.php?id='.$imageid.'"><img src="http://www.mysite.net/uploads/'.$imgs[0]->link.'" border="0" alt=" " /></a><br /><a href="http://www.mysite.net"></a>" size="70" /> <br /> For posting in forums use this: <input name="textfield6" type="text" class="imagedetails_links" id="textfield6" onclick="this.select();this.focus()" value="[url=http://www.mysite.net][img]http://www.mysite.net/uploads/'.$imgs[0]->link.'[/img][/url]" size="70" /> <br /> </div> <div style="float:left; width:450px; margin-left:34px; margin-top:5px;"><table width="100" border="0"> <tr> <td class="widgets"><a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></td> <td class="widgets"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmysite.net%2F&layout=box_count&show_faces=false&width=450&action=like&font=arial&colorscheme=light&height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:65px;" allowTransparency="true"></iframe></td> </tr> </table></div> '; if(ereg('.gif',$imgs[0]->link)){ $thelarge ="<img src='uploads/".$imgs[0]->link."' alt='".$imgs[0]->name."' style='border:0px solid #cccccc;' />"; }else{ $thelarge ="<img src='imageresize.php?imagepath=uploads/".$imgs[0]->link."&width=500&height=500' alt='".$imgs[0]->name."' style='border:0px solid #cccccc;' />"; } $d[]=" </div> <div style='float:left; margin-left:10px;'> <p style='padding:0; margin:0; margin-right:20px; text-align:center; font-size:14px;'><a href='force.php?path=uploads/".$imgs[0]->link."'>Click to Download Image</a></p><br /> ".$thelarge." <div style='overflow:auto; clear:both'> <div style='float:left; text-align: left;'> Image: <span style='color:#FFFFFF;'>{$imgs[0]->name}</span><br /> <span style='color:#ffffff; font-size:13px;'>Posted on: ".date('m-d-Y',$imgs[0]->date_added)." by ".ucfirst($theuser)."</span> </div> <div style='float:right'> <!-- Insert unique view count --> <span style='color:#ffffff; font-size:13px;'>Views: $_views</span> </div> </div> ".' </div> <div style="clear:both;"></div> <div style="margin:0 auto;"><br />'.$err.' <form action="'.$_SERVER['PHP_SELF'].'" method="post" style="margin:0 auto; width:400px; color:#ffffff; font-size:11px; text-align:left;"> <div style="margin-bottom:5px;">Leave a comment:</div><input type="hidden" name="id" value="'.$imageid.'" /> Your name: <input type="text" name="thename" style="width:250px;" class="inputfields" value="'.$_SESSION['username'].'"/><br /> Your comment:<br /><textarea name="thecomment" style="width:400px; height:70px;" cols="50" rows="4" class="textareas" ></textarea><br /> <input type="submit" name="submit" value="Post Comment" style="float:right;"/> </form> </div>'; $getallcomments = $ezdb->get_results("SELECT * FROM user_comments WHERE image_id='".$imageid."' ORDER BY date_added DESC"); $uclist = '<div style="margin:0 auto; width:410px; padding:5px; border:0px solid #cccccc; margin-top:40px;">'; if(sizeof($getallcomments)>0){ foreach ($getallcomments as $ac){ $uclist .='<div style="border-bottom:2px solid #333333; width:400px; color:#ffffff; font-size:12px; margin:0 auto; text-align:left;"><br />Posted on:<span style="color:#000000;"> '.date('m-d-Y',$ac->date_added).' at '.date('H:i a',$ac->date_added).'.</span><br />Posted by:<span style="color:#000000;"> '.strip_tags($ac->posted_by).'</span><br /><span style="color:#ffffff;">'.strip_tags($ac->message).'</span></div>'; } }else{ $uclist.='<div style="border-bottom:2px solid #ffffff; width:400px; color:#ffffff; font-size:12px; margin:0 auto; text-align:center;">Be the first to leave a comment!</div>'; } $uclist.="</div><div style='clear:both;'></div><br /><br />"; $d[] = $uclist."</div>"; $page->add($d); echo $page->render(); ?> Hi, Today I have taken my first step towards familiarisation with php. I have created a simple form form a tutorial I read. The mail.php file is this: Code: [Select] <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $dropdown = $_POST['dropdown']; $formcontent=" From: $firstname \n Surname: $lastname \n Email: $email \n Dropdown: $dropdown"; $recipient = "fathernugen@googlemail.com"; $subject = "Newsletter Sign Up"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "You have been added to our newsletter subscription list!" . " -" . "<a href='newsletter.php' style='margin:0 auto; top: 100px; text-decoration:none;color:#ff0099;'> Return to Sitting Spiritually</a>"; ?> My problem is that users are redirected to a blank page with 'thank you return to sitting spiritually'. I would like to use a custom thank you page with a url like; www.sittingspiritually.co.uk/thankyou.php so the look of the site is not completely ruined by my php inadequacies. Is there a small piece of code i can add to the mail.php file so i can use a custom page for the success??? I hope some one can help, thanks in advance. Hi! I am not great at using php but do use it to process forms on websites. I always use the same script and just change the relevant sections for each website. This usually works with no problems. I am writing an mailing list subscribe/unsubscribe form my website and it works fine as in I get the email sent through with all the information on it and the automated reply gets sent out etc. The problem is that once the user hits Submit instead of going to the redirect page it stays on the php page. if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a company name, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: http://www.hillsideweb.co.uk/unsubthanks.html" );} Like I say this exact script works on another site of mine perfectly well, can someone please help me solve this. The form is found on http://www.hillsideweb.co.uk/unsubscribe.html I hope this makes sense! Many thanks Swenglish Hi, I have a php form that I use to try to get matching data from the database that I put into the form. So if I enter date of birth 9-4-80 and first name Dave and lastname Smith. When I submit it the code should pull all of the matching terms out of the database and display. Now I get the following error when I submit the form. Query: Resource id #2 Failed with error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #2' at line 1 any help Greatly appreciated. thank you! here is the code Code: [Select] <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $host = " "; $database = " "; $username = " "; $password = " "; $tbl_name = "users"; $conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error()); if($conn) { mysql_select_db($database); echo "connected to database!!"; } else { echo "failed to select database"; } //include('bouncer.php'); //$currentUser = $_SESSION['myusername']; if(isset($_POST['submit'])) { $first = mysql_real_escape_string( $_POST['first']); $last = mysql_real_escape_string( $_POST['last']); $dob = mysql_real_escape_string( $_POST['dob']); //THE SEARCH FUNCTION $sql = mysql_query ( "SELECT * FROM users WHERE firstname LIKE '%$first%' OR lastname LIKE '%$last%' OR dob LIKE '%$dob%' ") or die(mysql_error()); $result = mysql_query($sql) or die( "<br>Query: $sql<br>Failed with error: " . mysql_error() ); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["firstname"]; echo $row["lastname"]; echo $row["dob"]; } }//if(isset($_POST['submit'])) ?> <html> <body> <form action="login_success8.php" method="post"> <p> <input type="text" name="first" size="20" /> First name<br /> <input type="text" name="last" size="20" /> Last name<br /> <input name="dob" type="text" size="20" id="dob" /> Date of Birth<br /> <input type="submit" name="submit" value="Search" /> <input type="reset" value="Reset fields" /> </p> </form> </body> </html> I'm having trouble with this form. I can't seem to figure out the rest of what is required I have already done most of it...I'm just stuck on these parts: Province Select : (AutoGeneration, Multiple Select, Memory) AutoGeneration using Provinces Array: The Province Select box is generated by PHP using this array: provinces.txt Cut and paste this array into your own code. Multiple Selections: Note that the province select box permits multiple values to be selected. View the HTML source to see the configuration details. Also note how $_POST delivers these multiple values as an array. Select Box Memory: The Province select box retains the user choices after a POST. For each province selected by the user, your code will generate the "selected" attribute in the <options> tag for that province. View the HTML source of the working solution to see how this works. Status CheckBoxes (Multiple Select, Memory) Multiple Selections: Note that these checkboxes have been configured in the HTML to permit multiple selections. Also note that $_POST delivers these multiple selection values in an array. Status Box Memory:The Status Box retains the user choices after a POST. Your code will need to generate the "checked" attribute in the <input> tag for each item selected. Do not generate the checkboxes with an array. Location Radio button: Do not generate the radio buttons with an array. The Location radio button retains the user choice after a POST. Validation Success Message: Where does it go - The final success message is placed within the <div class="success"></div> tags at the top of the HTML. Use a Loop: Generate the success message with a single array loop that reads the $_POST array and prints out the success message as an ordered list. Form Variables List Un-Ordered List - The form variables are displayed in an unordered list . CSS removes the bullet. Names Capitolised - The names of the form variables are capitolised ( use strtoupper() function ) . Handle Empty Values - Print "---None supplied---" if the variable is empty. Province Long Names - Print the long names of the provinces selected as comma separated string Status Choices - Print the status choices as a comma separated string. Functions I need to use: empty() - is the string empty. Unfortunately, a "0" value counts as an empty string. strlen() - returns the number of characters in a string. is_numeric() - is the string a number count() - how many rows in an array is_array() - is the variable an array isset() - does the variable or member of array exist in_array() -does this string exist in this array strtoupper() - convert string to upper case. join() - you'll want this one too. Converts an array of strings into a string with a delimiter. error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); - suppresses warning messages in your code. Place at top. foreach ($_POST as $KEY => $VAL) {} - walk through the $_POST array (or any array) My code: Code: [Select] <!--"StAuth10065: I Adam Graham, 000136921 certify that this material is my original work. No other person's work has been used without due acknowledgement. I have not made my work available to anyone else."--> <? $PROVINCES = array( "--" => "--- Please Select Provinces ---", "nf"=>"Newfoundland", "pe"=>"Prince Edward Island", "nb"=>"New Brunswick", "ns"=>"Nova Scotia", "qc"=>"Quebec", "on"=>"Ontario", "mb"=>"Manitoba", "sk"=>"Saskatchewan", "ab"=>"Alberta", "bc"=>"British Columbia", "nt"=>"Northwest Territories"); if ($_SERVER['REQUEST_METHOD'] == 'GET') { $dimwelcomeMsg = TRUE; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_POST['uname'] == ''){ $errMsgs['uname'] = "Username must not be blank!!!"; $unameInError = true; } if (empty($_POST['year']) == TRUE){ $errMsgs['year'] = "Year must not be blank!!"; } if (count($errMsg) > 0 ): $dispErrorMsg = TRUE; else: foreach ($_POST as $key => $val): $key = strtoupper($key); $successMsg[$key] = $val; endforeach; $dispSuccessMsg = TRUE; endif; } ?> <html > <head> <title>Comp10065 - Simple Form Validatioon</title> <style type="text/css"> body { margin: 0; padding: 0; font: 80%/1.5 Arial,Helvetica,sans-serif; color: #111; background-color: green; } h2 { margin: 0px; padding: 10px; font-family: Georgia, "Times New Roman", Times, serif; font-size: 200%; font-weight: normal; color: #FFF; background-color: #CCC; border-bottom: #BBB 2px solid; } h1 {color:#006600} p#copyright { margin: 20px 10px; font-size: 90%; color: #999; } div.form-container { margin: 10px; padding: 5px; background-color: #FFF; border: #EEE 1px solid; } p.legend { margin-bottom: 1em; } p.legend em { color: #C00; font-style: normal; } div.errors { margin: 0 0 10px 0; padding: 5px 10px; border: #FC6 1px solid; background-color: #FFC; } div.errors p { margin: 0; } div.errors p em { color: #C00; font-style: normal; font-weight: bold; } div.success { margin: 0 0 10px 0; padding: 5px 10px; border: #FC6 1px solid; background-color: #FFC; } div.success p { margin: 0; color:#006633} div.success li {list-style-type: none; } div.form-container form p { margin: 0; } div.form-container form p.note { margin-left: 170px; font-size: 90%; color: #333; } div.form-container form fieldset { margin: 10px 0; padding: 10px; border: #DDD 1px solid; } div.form-container form legend { font-weight: bold; color: #666; } div.form-container form fieldset div { padding: 0.25em 0; } div.form-container label, div.form-container span.label { margin-right: 10px; padding-right: 10px; width: 150px; display: block; float: left; text-align: right; position: relative; } div.form-container label.error, div.form-container span.error { color: #000; } div.form-container select.error, div.form-container div.error {background-color: #FEF;} div.form-container label em, div.form-container span.label em { position: absolute; right: 0; font-size: 120%; font-style: normal; color: #C00; } div.form-container input.error { border-color: #C00; background-color: #FEF; } div.form-container input:focus, div.form-container input.error:focus, div.form-container textarea:focus { background-color: #FFC; border-color: #FC6; } div.form-container div.controlset {margin: 3px} div.form-container div.controlset label, div.form-container div.controlset input { display: inline; float: none; } div.form-container div.controlset div { margin-left: 170px; } div.form-container div.buttonrow { padding-left: 430px; border: 1px solid #CCCCCC } div#wrapper {width: 700px ; margin-left: auto; margin-right: auto} pre {color:black; font-size: 10pt; font-weight: bold; margin-left: 30px} </style> </head> <body> <div id="wrapper"> <h1> Form Validation Lab</h1> <div class="form-container"> <? if ($_SERVER['REQUEST_METHOD'] == 'GET') : ?> <? if (displayWelcomeMsg) : ?> <p>Please fill in the form........</p> <? endif; ?> <? endif; ?> <? if ($displaySuccessMsg): ?> <div class="success"> <p>Thank you for your submission.</p> <ol> <? foreach($successMsgs as $key => $successMsg): ?> <li><?= $key ?> = <?= $successMsg ?> </li> <? endforeach; ?> </ol> </div> <? endif; ?> <? if ($dispErrorMsg) : ?> <div class="errors"> <p><em>Oops...the following errors were encountered</em></p> <ul> <? foreach ($errMsgs as $key => $errMsg): ?> <li><?= $errMsgs ?> </li> <? endforeach; ?> </ul> <p>Please correct the errors and re-submit this form.</p> </div> <? endif; ?> <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post"> <input type="hidden" name="act" value="post"> <div class="buttonrow"> <input type="submit" value="Submit This Form " class="button" /> <a href="<?= $_SERVER['PHP_SELF'] ?>" >Start Again</a> </div> <p class="legend"><strong>Note:</strong> Required fields are marked with an asterisk (<em>*</em>)</p> <fieldset> <legend>User Details</legend> <div> <label for="uname" >User Name <em>*</em></label> <? if (isset($errMsgs['uname'])) echo 'class = "errors"' ?> <input id="uname" type="text" name="uname" value="<?=$_POST['uname'] ?>" /> (must be greater than 5 chars)</div> <div> <label for="email">Email Address </label> <input id="email" type="text" name="email" value="" /> </div> </fieldset> <fieldset> <legend>Submission</legend> <div> <label for="year">Year (YYYY) <em>*</em></label> <input id="year" type="text" name="year" <? if (isset($errMsgs['year'])) echo 'class = "errors"' ?> value="" size="4" maxlength="4" /> (4 digit number)</div> <div> <label for="date">Month (MM)</label> <input id="date" type="text" name="month" value="" size="4" maxlength="2" /> (number ranging from 1-12)</div> </fieldset> <fieldset> <legend>Preferences</legend> <div> <label for="type" >Province (Multiple Select) <em>*</em></label> <select name = "province[]" multiple size = "12" id="type" > <? foreach ($PROVINCES as $abbreviation => $longname); ?> <option value = "<?=$abbreviation ?> "></option> <? enfgoreach; ?> </select> </div> <div class= 'controlset' > <span class="label">Status (Mult Select)<em>*</em></span> <input name="status[]" id="approved" value="approved" type="checkbox" /> <label for="approved">Approved</label> <input name="status[]" id="pending" value="pending" type="checkbox" /> <label for="pending">Pending Application</label> <input name="status[]" id="actives" value="actives" type="checkbox" /> <label for="actives">Active Service</label> </div> <div class= 'controlset'> <span class="label"> Location <em>*</em></span> <input name="location" id="radio1" value="Garage" type="radio" /> <label for="radio1">Garage</label> <input name="location" id="radio2" value="Attic" type="radio" /> <label for="radio2">Attic</label> <input name="location" id="radio3" value="House" type="radio" /> <label for="radio3">House</label> </div> </fieldset> </form> <p>This debug info is here to help you. You are only required to display the POST array</p> <pre><?= print_r($_POST,true) ?> </pre> </div> </div> </body> </html> Hello, I am trying to use this contact form that emails out. however it wants to be placed beside the file that uses it. However i would need a bunch of these files than for what i am trying to do. I want it to be set up like this. website root | | scripts | scriptfile right now its like this website root | | about | | contact | | script file here is the from data in my webpage <form action="FormToEmail.php" method="post"> <table border="0" style="background:#ececec" cellspacing="5"> <tr align="left"><td>Name</td><td><input type="text" size="30" name="name"></td></tr> <tr align="left"><td>Email address</td><td><input type="text" size="30" name="email"></td></tr> <tr align="left"><td valign="top">Comments</td><td><textarea name="comments" rows="6" cols="30"></textarea></td></tr> <tr align="left"><td> </td><td><input type="submit" value="Send"></td></tr> </table> </form> here is the script data <?php error_reporting(E_ALL ^ E_NOTICE); $my_email = "test@test.com.com"; $from_email = ""; /* Optional. Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage. If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm" */ $continue = "/"; /* Step 3: Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! THAT'S IT, FINISHED! You do not need to make any changes below this line. */ $errors = array(); // Remove $_COOKIE elements from $_REQUEST. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}} // Validate email field. if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) { $_REQUEST['email'] = trim($_REQUEST['email']); if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ") || stristr($_REQUEST['email'],"\\") || stristr($_REQUEST['email'],":")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}} } // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($_REQUEST); if(!$set){$errors[] = "You cannot send a blank form";} unset($set); // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} // Build message. function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");} $message = build_message($_REQUEST); $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL.""; $message = stripslashes($message); $subject = "Doctor Dave Question"; $subject = stripslashes($subject); if($from_email) { $headers = "From: " . $from_email; $headers .= PHP_EOL; $headers .= "Reply-To: " . $_REQUEST['email']; } else { $from_name = ""; if(isset($_REQUEST['name']) && !empty($_REQUEST['name'])){$from_name = stripslashes($_REQUEST['name']);} $headers = "From: {$from_name} <{$_REQUEST['email']}>"; } mail($my_email,$subject,$message,$headers); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Form To Email PHP script from FormToEmail.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000"> <div> <center> <b>Thank you <?php if(isset($_REQUEST['name'])){print stripslashes($_REQUEST['name']);} ?></b> <br>Your message has been sent <p><a href="<?php print $continue; ?>">Click here to continue</a></p> </center> </div> </body> </html> thank you. on a side note the text box wher ei entered this in is anoyying. it jumps and bounces every letter i type. Hello, I have just finished very simple contact form at http://stjohnsclaims.co.uk/test5/index-6.html and I am strugling to redirect the page to index.html, or any other URL when buttom "submit" is pressed. html file always reads contact.php file and then echo ("Your claim form was successfully sent!"); on blank background. How can I redirect it? I know this is very trivial question, but I have alrready spend many hours trying to fix it with no result. Thank you html body.... <div class="indent1"> <h2>Claim Form</h2> <form action="contact.php" method="get" id="form"><div class="container"> <div class="col-5"><h4>Your Details:</h4> <div class="h"><input name="name" type="text" class="input1" />Name:</div> <div class="h"><input name="surname"type="text" class="input1" />Surname:</div> <div class="h"><input name="tel"type="text" class="input1" />Tel:</div> <div class="h"><input name="email"type="text" class="input1" />Email Adress:</div> <div class="h"><input name="address"type="text" class="input1" />Address:</div> <div class="h"><input name="city"type="text" class="input1" />City:</div> <div class="h"><input name="postcode"type="text" class="input1" />Postcode:</div><p> <h4>Accident Details</h4> <div class="h"><input name="date"type="text" class="input1" />Date of Accident:</div> <div class="h"><input name="type"type="text" class="input1" />Accident Type:</div> </div> <div class="col-6">Accident details/Injuries sustained:</div> <div class="col-7"> <textarea name="message" class="textarea" rows="40" cols="30"></textarea> <div class="container1"> <div class="fright"> <a href="#" onclick="document.getElementById('form').reset()" class="link-1"><em><b>Clear</b></em></a> <div class="indent-2"> <a href="#" onclick="document.getElementById('form').submit()" class="link-1"><em><b>Submit</b></em></a></div> </div> </div> </div> </div></form> --------------------------------------------------------------- contact.php on the server <? $subject="from ".$_GET['name']; $headers= "From: ".$_GET['email']."\n"; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("kc@kamil-cizek.com", $subject, " <html> <head> <title>Contact letter</title> </head> <body> <br> " . "name: " .$_GET['name']. "<br>" . "email: " .$_GET['surname']. "<br>" . "fax: " .$_GET['tel']. "<br>" . "age: " .$_GET['email']. "<br>" . "gender: " .$_GET['address']. "<br>" . "name: " .$_GET['city']. "<br>" . "email: " .$_GET['postcode']. "<p>" . "fax: " .$_GET['date']. "<br>" . "age: " .$_GET['type']. "<p>" . "message: <p>" .$_GET['message']." </body> </html>" , $headers); echo ("Your claim form was successfully sent!"); ?> Ok so I already have a "post" action URL, here it is below. <form method="post" action="http://survey.leisuretrends.com/RemoteSurvey.asp?survey=321&survey_version=1330"> The idea is to put a simple e-mail form on my personal website: And have the post action to go to the URL above (its a marketing company for email submissions / newsletters) Here is what I have so far, but I know something is not right: Quote <form> <input type="text" /> <input type="submit" /> <form method="post" /> <form action="http://survey.leisuretrends.com/RemoteSurvey.asp?survey=321&survey_version=1330"/> </form> Any help would be greatly appreciated. Thank you for your patience with me Hi, I am new to php, and I have run into a problem. The tutorial I am using has provided me with this exact code. But it does not work for me. Its very simple. Here is the HTML page: Code: [Select] <body> <FORM ACTION="welcome.php" METHOD=POST> First Name: <INPUT TYPE=TEXT NAME="name"> <INPUT TYPE=SUBMIT VALUE="GO"> </FORM> </body> And here is the php page: <body> <?php echo( "Welcome to our Web site, $name!" ); ?> </body> You can see the problem live at <http://www.freewaycreative.com/test> (dont mind the digits below) The name just does not show. Anyone know why? Thanks! hi iam trying to make a simple search form to search the members tables based on there input. iam new php so most of my code is guess work Code: [Select] <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> <label for="country">Country:</label> <input type="text" name="country" /> <label for="state">State:</label> <input type="text" name="state" /> <label for="city">City:</label> <input type="text" name="city" /> <input type="submit" value="submit" /> </form> <? if ($_GET == array ()) { //Define a variable that will be used to query the members; in this case, it would select all members $query = "SELECT * FROM users"; } else { //If the user typed at least one thing (in the form OR the url) if (count ($_GET) == 1) { //If what they typed is only for one criteria, define a variable that creates a query for only ONE criteria to search for $query = "SELECT * FROM users WHERE 1"; foreach ($_GET as $field => $value) { $query .= " AND $field = '$value'"; } //If the user has typed in more than one field and hits search } else { //Define a variable for a query that selects members based off each criteria $query = "SELECT * FROM users WHERE 1"; foreach ($_GET as $field => $value) { $query .= " AND $field LIKE '%$value%'"; } } while($info = mysql_fetch_array( $data )) { Echo "<img src='http://datenight.netne.net/images/".$info['img'] ."' width='150' height='250''> <br>"; Echo "<b>Name:</b> ".$info['username'] . "<br> <hr>"; Echo "<b>Sex:</b> ".$info['sex'] . " <br><hr>"; Echo "<b>Intrested in</b>" . "<br><hr>"; Echo "".$info['rel'] . " "; Echo "".$info['frwb'] . " "; Echo "".$info['ons'] . " "; Echo "".$info['fr'] . "<br><hr>"; Echo "<b>About me:</b> ".$info['aboutme'] . "<br><hr> "; Echo "<b>Looking for:</b> ".$info['looking'] . " <br><hr>"; Echo "<a href='login_success.php'>'Back'</a>"; } ?> </body> </html> while($info = mysql_fetch_array( $data )) { is not vaild error I am trying to add some simple validation to my form. I only wanter users to be able to enter 11 numbers into the number field or else it will say 11 digit numbers only. A validation to only allow users to input numbers anything else and it brings up an error. and finally i want to check the email string to make sure it has an @ and a (.) . How would i go about adding these validation techniques to this code? <?php if ($_SERVER['REQUEST_METHOD']=="POST"){ // Recipent Email $to="andrew@peppermintdigital.com"; $subject="Reply to Peppermint Invitation"; $title = $_POST['title']; $name = stripslashes($_POST['name']); $add1 = stripslashes($_POST['add1']); $add2 = stripslashes($_POST['add2']); $add3 = stripslashes($_POST['add3']); $add4 = stripslashes($_POST['add4']); $postcode = stripslashes($_POST['postcode']); $number = stripslashes($_POST['number']); $email = stripslashes($_POST['email']); $time = $_POST['time']; $from = ($_POST['name']) . "<".stripslashes($_POST['email']).">"; $subject = ($_POST['name']) . "<".stripslashes($_POST['email']).">"; // Email Message $message = "Name : $title $name. Address : $add1, $add2, $add3, $add4, $postcode. Phone Number : $number. Email : $email. Appointment Time : $time"; // Validation Begins // Add Erros To Array $errors = array(); // Check Form if (!$_POST['title']) $errors[] = "Title Required"; if (!$_POST['name']) $errors[] = "Name Required"; if (!$_POST['add1']) $errors[] = "Address Required"; if (!$_POST['add4']) $errors[] = "City Required"; if (!$_POST['postcode']) $errors[] = "Postcode Required"; if (!$_POST['number']) $errors[] = "Number Required"; if(!$_POST['number'] == 11) $errors[] = "Full Number Required"; if (!$_POST['email']) $errors[] = "Email Required"; if (!$_POST['time']) $errors[] = "Time Required"; // Display Errors if (count($errors)>0) { echo"<h1 class='fail'>"; foreach($errors as $err) echo "$err.\n"; echo"</h1>"; echo " <form method='post' action='#'> <table cellpadding='0' cellspacing='0' border='0'> <tr> <td class='form_results' colspan='2'> </td> </tr> <tr> <td class='form_left' valign='top'> <table width='200' border='0' cellspacing='0' cellpadding='0'> <tr> <td class='title_left' valign='top'>Title</td> </tr> <tr> <td class='sname_left' valign='top'>Name</td> </tr> <tr> <td class='add_left' valign='top'>Address</td> </tr> <tr> <td class='post_left' valign='top'>Postcode</td> </tr> <tr> <td class='number_left' valign='top'>Phone Number</td> </tr> <tr> <td class='email_left' valign='top'>Email Address</td> </tr> <tr> <td class='time_left' valign='top'>Appointment Time</td> </tr> </table> </td> <td class='form_right' valign='top'> <table width='300' border='0' cellspacing='0' cellpadding='0'> <tr> <td class='right_spacer'> <select name='title' class='select'> <option>Mr</option> <option>Mrs</option> <option>Ms</option> <option>Miss</option> </select> </td> </tr> <tr> <td class='right_spacer'><input type='text' name='name' class='field' value='$name' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add1' class='field' value='$add1' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add2' class='field' value='$add2' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add3' class='field' value='$add3' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add4' class='field' value='$add4' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='postcode' class='field' value='$postcode' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='number' class='field' value='$number' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='email' class='field' value='$email' /></td> </tr> <tr> <td class='right_spacer'> <select name='time' class='select'> <option>5.30 pm</option> <option>6.30 pm</option> <option>7.30 pm</option> </select> </td> </tr> </table> </td> </tr> <tr> <td class='form_buttom' colspan='2'> <input name='submit' type='submit' value='Submit' class='submit_button' /> </td> </tr> </table> </form> "; } else { // Build message headers $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; // Send message if (@mail($to, $subject, $message, $headers)) echo "<h1 class='success'>Your message has been sent.</h1>"; else echo "<h1 class='fail'>Your message was not sent at this time.</h1>"; } } else { echo " <form method='post' action='#'> <table cellpadding='0' cellspacing='0' border='0'> <tr> <td class='form_results' colspan='2'> </td> </tr> <tr> <td class='form_left' valign='top'> <table width='200' border='0' cellspacing='0' cellpadding='0'> <tr> <td class='title_left' valign='top'>Title</td> </tr> <tr> <td class='sname_left' valign='top'>Name</td> </tr> <tr> <td class='add_left' valign='top'>Address</td> </tr> <tr> <td class='post_left' valign='top'>Postcode</td> </tr> <tr> <td class='number_left' valign='top'>Phone Number</td> </tr> <tr> <td class='email_left' valign='top'>Email Address</td> </tr> <tr> <td class='time_left' valign='top'>Appointment Time</td> </tr> </table> </td> <td class='form_right' valign='top'> <table width='300' border='0' cellspacing='0' cellpadding='0'> <tr> <td class='right_spacer'> <select name='title' class='select'> <option>Mr</option> <option>Mrs</option> <option>Ms</option> <option>Miss</option> </select> </td> </tr> <tr> <td class='right_spacer'><input type='text' name='name' class='field' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add1' class='field' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add2' class='field' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add3' class='field' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='add4' class='field' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='postcode' class='field' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='number' class='field' /></td> </tr> <tr> <td class='right_spacer'><input type='text' name='email' class='field' /></td> </tr> <tr> <td class='right_spacer'> <select name='time' class='select'> <option>5.30 pm</option> <option>6.30 pm</option> <option>7.30 pm</option> </select> </td> </tr> </table> </td> </tr> <tr> <td class='form_buttom' colspan='2'> <input name='submit' type='submit' value='Submit' class='submit_button' /> </td> </tr> </table> </form> "; } ?> I have an error somewhere in the form as it does not output what I want it too. I know the form itself is working as I have added an echo to see if the form inputs are processed. the code: Code: [Select] <?php $amount = $_POST['amount']; $member = $_POST['member']; $sql = ("SELECT name FROM vtp_members WHERE name=".$member." "); $result = mysql_query($sql); $numrows = mysql_num_rows($result); if($numrows = '1') { while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "You sent ". $amount . " to " . $member . ".<br />"; } } echo " ".$amount." and ".$member." "; ?> It outputs the last echo correct. is there anyone who can see what I'm doing wrong? Alright so I am trying to code a very simple form that adds a user to my SQL database with certain information filled in and certain information kept hidden with default values in a form. My index.php file is as follows (not all of the code but just the form part): <?PHP $submitMessage = $_GET['value']; if ($submitMessage == success) { echo '<div class="congratulations"><font color="#84d20c"><strong>Congratulations:</strong></font> The user has been added.</div>'; }else if($submitMessage == NULL){ }else if($submitMessage == fail){ echo '<div class="error"><font color="#d3430c"><strong>Error:</strong></font> An error occurred please check the error details below:</div>'; echo 'ERROR DETAILS:'; echo mysql_error(); } ?> <h1><i>Add User</i></h1> <p>This page is where you would manually add a user to the donations databases (for example you or a member of the community with elevated status that does not need to pay).</p> <br/> <form enctype="multipart/form-data" action="scripts/admin_save_sm_db.php" method="post"> <input name="authtype" value="steam"/><br /><br /> <h3><i>STEAM ID:</i></h3> <input name="identity" value="STEAM_0:X:XXXXXXXX"/><br /> <div class="form_help">Steam ID of the player you wish to add. Must be in the format STEAM_0:X:XXXXXXXX</div><br /> <input name="flags" value="o"/><br /><br /> <input name="name" value="Donator"/><br /><br /> <input name="immunity" value="0"/><br /><br /> <h3><i>Your Email Address</i></h3> <input name="user_email"/><br /> <div class="form_help">Your Email Address for security purposes.</div><br /> <input name="Submit" type="submit" value="Submit" class="form_submit" /> </form> My admin_save_sm_db.php file is as follows: <?php session_start(); if(!isset($_SESSION["username"])) { header('Location: login.php'); exit; } @require("../sm_admin_db.php"); $authtype = $_POST['authtype']; $identity = $_POST['identity']; $flags = $_POST['flags']; $name = $_POST['name']; $immunity = $_POST['immunity']; $user_email = $_POST['user_email']; $link = @mysql_connect(_HOST,_USER,_PASS); @mysql_select_db(_DB); $sql = @mysql_db_query(_DB,"INSERT INTO "._TBL." (`authtype`, `identity`, `flags`, `name`, `immunity`, `user_email`) VALUES (NULL, '$authtype', '$identity', '$flags', '$name', '$immunity', '$user_email')"); $okay = @mysql_affected_rows(); if($okay > 0) { header( "Location: ../index.php?value=success" ); } else { header( "Location: ../index.php?value=fail" ); } @mysql_close($link); ?> And finally my sm_admin_db.php file is as follows: <?PHP //host loaction define("_HOST", "localhost", TRUE); //database username define("_USER", "thatsact_admin", TRUE); //database username`s password define("_PASS", "*********", TRUE); //database name define("_DB", "thatsact_sadadmins", TRUE); //database table name change this to install multiple version on same database define("_TBL", "sm_admins", TRUE); //This is the email that you will recieve emails when someone signs up. define("_EMAIL", "admin@tag-clan.com", TRUE); ?> All of this together does not work and gives the echo error code, however the mysql_error() string does not return anything. Nothing is inserted into the database. Can I get some help on where I went wrong and please keep in mind I am VERY new to php and didn't write most of this script so just tell me what to edit and exactly how to do it please. Thanks in advance. |