PHP - Newbie Having Problems With Php Form For Database...
Hi there guys,
I am very new to php and mySQL and i am currently working on a new site which I want to create a form where my sit visitors can leave their details so i can send them emails with future promotions... I have uploaded the files and when testing the form there doesnt seem to be any errors messages, but then when i go to my phpMyAdmin to check i it has worked. I can not see any of the information to which i ave entered from the form n the website.. I would be very grateful if somebody can please help me... the code for the php is as below.. Many many thanks in advance.. <?php $username="rdo10000_robin"; $password="mypassword"; $database="rdo10000_email"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); mysql_query($query); $query = "INSERT INTO data1 VALUES ('$_POST[name]','$_POST[email]','$_POST[phone]','$_POST[country]','$_POST[age]')"; header('Location: fish.html'); mysql_close(); ?> I really hope some one can help, many thanks in advance Similar TutorialsHi guys, I've spent quite a bit of time searching the site and have a good start - hoping for some help. I run a hockey league and have a database that keeps our stats. Regular stats page is here - http://okchockey.com/stats/stats.php I need a web form that can update existing records in the database. Maybe I am going thru this the wrong way - please let me know. I know there's a better way than my current version. Basically I have a table that has fields of Week, Jersey, Name, Goals, Assists, Points, and Penatly_Min. Again - excuse the newbie-ness - what I did is have a record for each player for each week. I already pre-created a record for each player for each week. I just need a web form that will update these existing records. I already created one that can add new records but I am having a tough time creating one to update existing ones. I'd like to be able to select the week (week 1-10) then select a player and update his stats for that particular week. Hopefully this makes sense. If anyone has some sample code I can look at I'd sure appreciate it. Really struggling trying to teach myself PHP hi there. can someone tell me how to get this to print out the real minutes instead of the month? echo date("M-d-Y H:m:s", mktime()); i've read http://www.sqlite.org/lang_datefunc.html but i can't seem to get it to work. I am a complete newbie. I have installed xampp. I created a database and the tables but that is all. I need to create all my relationships and test my database. to do this, do I now need to write the php code to view the results in a browser or... do I do it in MySQL. If so, Can someone just point me in the direction I need to go for my next step.
Thanks
after cloasing connection of database i still got the values form database. Code: [Select] <?php session_start(); /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require_once '../database/db_connecting.php'; $dbname="sahansevena";//set database name $con= setConnections();//make connections use implemented methode in db_connectiong.php mysql_select_db($dbname, $con); //update the time and date of the admin table $update_time="update admin set last_logged_date =CURDATE(), last_log_time=CURTIME() where username='$uname'limit 3,4"; //my admin table contain 5 colums they are id, username,password, last_logged_date, last_log_time $link= mysql_query($update_time); // mysql_select_db($dbname, $link); //$con=mysql_connect('localhost', 'root','ijts'); $result="select * from admin where username='a'"; $result=mysql_query($result); mysql_close($con); //here i just check after closing data baseconnection whether i do get reselts but i do, why? echo "after the cnnection was closed"; if(!$result){ echo "cont fetch data"; }else{ $row= mysql_fetch_array($result); echo "id".$row[0]."usrname".$row[1]."passwped".$row[2]."date".$row[3]."time".$row[4]; } // echo "<html>"; //echo "<table border='1' cellspacing='1' cellpadding='2' align='center'>"; // echo "<thead>"; // echo"<tr>"; // echo "<th>"; // echo ID; // echo"</th>"; // echo" <th>";echo Username; echo"</th>"; // echo"<th>";echo Password; echo"</th>"; // echo"<th>";echo Last_logged_date; echo "</th>"; // echo "<th>";echo Last_logged_time; echo "</th>"; // echo" </tr>"; // echo" </thead>"; // echo" <tbody>"; //while($row= mysql_fetch_array($result,MYSQL_BOTH)){ // echo "<tr>"; // echo "<td>"; // echo $row[0]; // echo "</td>"; // echo "<td>"; // echo $row[1]; // echo "</td>"; // echo "<td>"; // echo $row[2]; // echo "</td>"; // echo "<td>"; // echo $row[3]; // echo "</td>"; // echo "<td>"; // echo $row[4]; // echo "</td>"; // echo "</tr>"; // } // echo" </tbody>"; // echo "</table>"; // echo "</html>"; session_destroy(); session_commit(); echo "session and database are closed but i still get values from doatabase session is destroyed".$_SESSION['admin']; ?> session is destroyed but database connection is not closed. thanks Hi Guys I am totally new to php and html and currently working on a project which is probably far to big for me! For reference - i am using dreamweaver and phpmyadmin. I have already created a regisration page and linked it to a database which works fine. But what i want to do now is to allow the user to upload a picture which will become the users profile picture and im really struggling. I had two seperate peices of code.. The first peice is the usual registration code which sends the data to the database and the second allows a user to upload an image to a folder on my server - both work fine on their own. What i THINK i need to do is try to merge the two peices of code and add an extra line somewhere which sends the file name and location to the users record on the database. the code i have so far is: Code: [Select] <form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Username:</td> <td><input type="text" name="username" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Password:</td> <td><input type="text" name="password" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">First Name:</td> <td><input type="text" name="fname" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Surname:</td> <td><input type="text" name="sname" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Email:</td> <td><input type="text" name="email" value="" size="32" /></td> </tr> <tr valign="baseline"> <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","100"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="profpics/".$image_name; //Writes the information to the database mysql_query("INSERT INTO users (prof_pic) VALUES ('$image_name')"); //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfull! </h1>"; } ?> <td nowrap="nowrap" align="right">Pictu </td> <td> <input type="file" name="photo"></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input name="Submit" type="submit" id="Submit" value="Submit" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> When a new user registers - the data is sent to the database but the image isnt uploaded or referenced in the DB Can anybody please help...Sorry if this is all mddled up but im pretty confused at the minute Thanks in advance The following code works: Code: [Select] @ $db = new mysqli('localhost', 'username', 'password', 'database'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "select * from model order by name asc"; $result = $db->query($query); However, I just started to include connect.php to my pages. Now I'm getting an error saying: "Fatal error: Call to a member function query() on a non-object on line 14" Here's my connect.php Code: [Select] .... $db = mysql_select_db($dbase , $connection) or die ("Can't select database."); Line 14 is... $result = $db->query($query); Any ideas? I believe it's the $db variable causing the problem. Ok, the point of this code is I want a user to be able to create a campaign, two things need to be unique when creating a campaign, the name and the keyword. The name needs to be unique to the table, and the keyword needs to be unique to the user. I can't seem to figure it out and I'm sure it's a problem with my SQL queries. Any help is appreciated if($user && $name && $pw && $kw && $desc && $reply) { //Check for a UNIQUE campaign Name $q = "SELECT user_id FROM campaigns WHERE name='$name'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); $qq = "SELECT name FROM campaigns WHERE (user_id={$_SESSION['user_id']} AND keyword='$kw')"; $rr = mysqli_query ($dbc, $qq) or trigger_error("Query: $qq\n<br />MySQL Error: " . mysqli_error($dbc)); if(mysqli_num_rows($r) == 0) // Campaign Name is Unique { if(mysqli_num_rows($rr) == 0) // Keyword is Unique to user { //Add campaign to database $q = "INSERT INTO campaigns (user_id, name, description, password, keyword , reply, creation_date) VALUES ('$user', '$name', '$desc', '$pw', '$kw', '$reply', NOW() )"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); //If it ran OK if(mysqli_affected_rows($dbc) == 1) { echo '<p>Campaign Successfully Created</p>'; include('footer.html'); exit(); } else { echo '<p>Campaign could not be created</p>'; } } else { echo 'Keyword is not unique'; } } else //campaign name is not UNIQUE { echo 'Your campaign name is not unique'; } } else { echo 'There was a problem creating your new campaign'; } mysqli_close($dbc); } i'm working on a project that stores records of architecture and architects. What i have to do is create a way for users to search the records in a simple way. The user can search by Building name, Architect, Location, Date it was built, Building type and architecture style. Currently i can only search properly by building name, date, type and style. If i add architect to the search query the records screw up when i try to search for the other fields individually..so for example if i add the architect to the query and try to only search by building name the results get screwed up and it displays more results that don't have nothing in comon rather than just display one result which would be the building name Like i said this only happens if i add the "architect" to the query Since the architect, location, date, type and style are stored in different tables i search for them first and get the id. Once i've grabbed the ID for those fields i do the actual search to get the buildings that match those records by ID In the actual query i use the OR statement to search all 5 fields regardless if the user left them empty. So if th user only searches for a building name it the query will basically search for the buildingID OR the rest of the fields as well. I hope someone here can help me figure out why when i add the architect field to the query the results get screwed up. I have the code displayed below: <?php if(isset($_POST['search'])){ $building = mysql_real_escape_string($_POST['building']); $architect = stringForUrl($_POST['architect']); $date = mysql_real_escape_string($_POST['date']); $style = mysql_real_escape_string($_POST['style']); $type = mysql_real_escape_string($_POST['type']); $find_building = mysql_query("SELECT * FROM points WHERE name LIKE '$building'") or die(mysql_error()); $tmp_building = mysql_fetch_assoc($find_building); $buildingID = $tmp_building['id']; $find_architect = mysql_query("SELECT * FROM architects WHERE full_name LIKE '$architect'") or die(mysql_error()); $tmp_architect = mysql_fetch_assoc($find_architect); $architectID = $tmp_architect['id']; $find_style = mysql_query("SELECT * FROM styles WHERE name LIKE '$style'") or die(mysql_error()); $tmp_style = mysql_fetch_assoc($find_style); $styleID = $tmp_style['id']; $find_type = mysql_query("SELECT * FROM types WHERE name LIKE '$type'") or die(mysql_error()); $tmp_type = mysql_fetch_assoc($find_type); $typeID = $tmp_type['id']; } ?> <?php if(isset($_POST['search'])){ $session_arch_id = $_SESSION['architect_id']; //query that does the actual search $get_search_points = mysql_query("SELECT * FROM points WHERE id='$buildingID' OR style_id='$styleID' OR type_id='$typeID' OR architect_id='$architectID' OR date='$date' ORDER BY name") or die(mysql_error()); $num_search_points = mysql_num_rows($get_search_points); print($get_search_points); ?> <h3>Architecure on the map</h3> <span id="num_buildings">Showing <?php echo $num_search_points; ?> buildings</span> <table width="605" cellspacing="0" cellpadding="5" border="0" id="wam_results-tbl"> <tr class="search_headings"> <td width="156">Building Name</td> <td width="114">Architect</td> <td width="45">Date</td> <td width="144">Building Type</td> <td width="96">Style</td> </tr> <?php while($points = mysql_fetch_assoc($get_search_points)){ $point_type_id = $points['type_id']; $point_style_id = $points['style_id']; $point_architect_id = $points['architect_id']; $point_firm_id = $points['firm_id']; ?> <tr> <td><?php echo $points['name']; ?></td> <td> <?php if(!empty($point_architect_id)){ $get_architect = mysql_query("SELECT * FROM architects WHERE id='$point_architect_id'") or die(mysql_error()); $architect = mysql_fetch_assoc($get_architect); echo ''.$architect['first_name'].' '.$architect['last_name'].''; }elseif(empty($point_architect_id)){ $get_firm = mysql_query("SELECT * FROM firms WHERE id='$point_firm_id'") or die(mysql_error()); $firm = mysql_fetch_assoc($get_firm); echo $firm['name']; } ?> </td> <td><?php echo $points['date']; ?></td> <td> <?php $get_types = mysql_query("SELECT * FROM types WHERE id='$point_type_id'") or die(mysql_error()); $type = mysql_fetch_assoc($get_types); echo $type['name']; ?> </td> <td> <?php $get_styles = mysql_query("SELECT * FROM styles WHERE id='$point_style_id'") or die(mysql_error()); $style = mysql_fetch_assoc($get_styles); echo $style['name']; ?> </td> </tr> <?php } ?> </table> <?php } ?> Hi. For a uni assignment I am turning my static prototype into a dynamic prototype and adding various features like templates, log in system and the ability to add/delete information stored on the database and view the information on the website. I have running into a problem though, I am having difficulties getting connected to the database, I don't know if this is something to do with the log in information though, below I have quoted the files. update.php (the script I use to connect to the database) Quote <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $name = $_POST['name']; $sname = $_POST['sname']; $address = $_POST['address']; $number = $_POST['number']; mysql_connect("localhost", "", "") or die ('error: ' .mysql_error()); mysql_select_db ("bza410_test"); $query="INSERT INTO testTable (id, firstname, surname, address, phone)VALUES ('NULL','".$name."', '".$sname."', '".$address."', '".$number."')"; mysql_query($query) or die ('error updating database'); echo "database updated with: " .$name. " ".$sname." ".$address." ".$number ; ?> after localhost I am aware password/username goes there, just removed them for obvious reasons. home.php Quote <?php $pagetitle = 'Welcome to ENSI'; require 'template/header.php'; ?> <p> This web page page was created on <strong> <?php echo date('l F jS \a\t Y h:i:s A \,'); if (date('H') < 12) { echo ' RISE AND SHINE!!!,'; } else { echo ' TIME TO SLEEP!!!,'; } ?> </strong> on the computer that is running on PHP. </p> <div> <p><strong>Please enter your name and birthday:-</strong></p> <form method="post" action="update.php"> <fieldset> <legend>Details</legend> <label>First Name:</label> <input type="text" name="name" /> <br/> <label> Surname:</label> <input type="text" name="sname" /> <br/> <label> Address </label> <input type="text" name="address" /> <br/> <label>Phone</label> <input type="text" name="number" /> <br/> <input type="submit" name="submit" value="submit" /> <input type="reset" name="reset" value="reset" /> </fieldset> </form> <?php if(isset ($_POST['submit'])) { $name = $_POST['name']; $sname = $_POST['sname']; $address = $_POST['address']; $number = $_POST['number']; echo htmlentities ($text); echo 'Hello, your first name is ' .$name; echo ' Your surname is ' .$sname; echo ' Your address is - ' .$address; echo ', Your phone number is - ' .$number; } ?> </div> <?php require 'template/footer.php'; ?> When I fill in the form and then press submit it goes to "error updating database" from the script, so have I got the server information wrong? Thanks Will. I bought this template, and so far the template creator has not really been able to help me figure out the php side of the template, which really frustrates me. I know very very basic php if at all, so I am a bit lost on how to get this contact form to work. I had filled in everything that I needed to on the php file, and then tested it out and it doesn't send the email and doesn't bring up a message of any kind or redirect. Here is the live site: http://www.johntheseoexpert.com [attachment deleted by admin] This is a bit of a wierd problem, but I haven't been able to solve it so I thought I'd post it up here. Basically, I'm using the following function to access Maxmind's GEO IP database (so that I can target visitors to my site based on their location): <?php // This code demonstrates how to lookup the country by IP Address include("geoip.inc"); // Uncomment if querying against GeoIP/Lite City. // include("geoipcity.inc"); $gi = geoip_open("/home/bounce6/public_html/geoIP/GeoIP.dat",GEOIP_STANDARD); $ip=$_SERVER['REMOTE_ADDR']; $country=geoip_country_code_by_addr($gi, "$ip"); geoip_close($gi); ?> The function is being called using this line from a separate file: include "/home/username/public_html/mydomain.com/functions/getCountry.php"; Now the code does what it's supposed to do, in as far as it's able to give me a string which details where a visitor is located. However, for some strange reason it seems to be adding a new HTML tag into my existing header tag. The code which has been inserted is as follows: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> </body> </html> I've managed to isolate the problem to this script, so I know that there must be an issue with it, but I'm not quite sure what it is. Can anyone suggest why this extra source code is being produced? Is there a particular function that I'm using which is forcing additional headers or something?! Any thoughts would be really appreciated! HI there, i'm using a flash and php form. The problem lie in the PHP I only seem to get the field titles (Name and telephone) coming through and not the data they contain. Could somebody tell me what i'm doing wrong? <?php $sendTo = "myemail@gmail.com"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ".$strtelephone."\r\n"; $message .= "message: ".$strmessage."\r\n"; mail($sendTo, $subject, $message, $headers); ?> thank you Working on a project for school and I am trying to code a form that feeds into a DB. I have been studying the syntax, reading and doing everything I can to get this to work. A little help, pointers, direction would be greatly appreciated. It may be my database structure so I included a image for anyone to see... and the files. Thanks in advance [attachment deleted by admin] Hello, I am just getting interested in PHP, so please excuse my ignorance. Something I thought might help me learn is this challenge. http://penn-station.com/gift2010.php is a daily enter sweepstakes. I'm wanting to automate a daily entry. I was able to do so using AutoIT (windows automation), but the result was rather janky. Anyways, I found how to enter my name in the Name field of the form by modifying the value attribute of the textbox. (I used Chrome's DOM inspector plug-in) <input type="text" class="EH_Form_Textbox" name="Name" size="30" value="Fred"> How would I go about actually submitting this? Thank you very much, Fred Hi, I'm a beginner to all this stuff, but I'm redesigning a website that needs an online booking form. I've made the form in HTML and the PHP bit to send direct to an email address. I found the template online. It works fine at sending to the email. But as soon as I started customising it and adding fields for "Date of Arrival" etc it's stopped working. I get a variety of error messages. Could you possibly take a look at it and see what I'm doing wrong? Thanks HTML (booknow.html) <form name="contactform" method="post" action="send_form_email.php"> <table width="450px"> </tr> <tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="first_name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top""> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="last_name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="30"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number *</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="arrival">Date of Arrival *</label> </td> <td valign="top"> <input type="text" name="arrival" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="comments">Comments</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> <a href="http://www.freecontactform.com/email_form.php"></a> </td> </tr> </table> </form> PHP bit (send_form_email.php) <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "MYEMAIL"; $email_subject = "SUBJECT"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) !isset($_POST['arrival']) !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $telephone = $_POST['arrival']; // required $comments = $_POST['comments']; // not required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!eregi($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($telephone) < 2) { $error_message .= 'The Telephone you entered does not appear to be valid.<br />'; } if(strlen($arrival) < 2) { $error_message .= 'The Date of Arrival you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Date of Arrival: ".clean_string($arrival)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you soon. <? } ?> I think something's wrong with the way I added Date of Arrival, but I don't know what. Thanks in advance for any advice Can anyone find a glaring error with my contact form or my mailer? I previously had a form that was working (sending the email through) but stopped working. It was more complicated before and had a recaptcha in it. I've been troubleshooting this for awhile now and can't figure out what's happening. I've stripped it down to just the basics. I'm stumped because I am correctly redirected to the confirmation.html page, yet no email has come through. I even put a simple test file (mailertest.php) on the server. The file is found and echoes "Mail sent", but no email is received. I contacted the host and they claim that things are fine on their end with the PHP mailer and it must be a problem in my code. As a newbie, I don't doubt that I'm doing something wrong, but I can't figure it out!
I'm attaching three files. Contact.php, contact_mailer.php and my test PHP file called mailertest.php. I'd appreciate any help that anyone can offer.
Attached Files
mailertest.php 99bytes
3 downloads
contact_mailer.php 608bytes
1 downloads
contact.php 7.55KB
0 downloads Hello JS experts,
I'm new to JS coding (self-learning) and I have just one (potenitally) simple request to ask of you wonderful folks here.
Oh BTW, I've tried searching through this forum (and the WWW as well) but couldn't seem to easily find something that fits my request, or was easy for me to understand and apply to my situation.
So what I have/want is: a Data-Entry form which (for the first record/entry for a given date) allows the user to select a date from a "Calendar Date Picker". Upon subsequent records/entries (for the same date), the date field should no longer be accessible, but the (previously entered/selected) value should be both displayed (greyed-out) and certainly carried over to the DB/Table.
I know this might be a very simple piece of code, but being that I'm a newbie, I'm not sure how to achieve this.
Would appreciate any and all help to get this done (preferably the necessary code).
If it helps, here's some of my existing code that's related to the field names:
Form field details:
<div class="control-group"> <label class='control-label'>Select Flyer Start Date:</label> <input type="text" name="datepicker" id="datepicker"> </div>DB (table) field details: $flyerDateStart = isset($_POST["datepicker"]) ? $_POST["datepicker"] : "";Thanks much. I have a form that looks like this: <form method="get"> Postcode:<input name="Postcode" type="text"><br> Name:<input name="Name" type="text"><br> <a href="#" onclick="popup('popUpDiv')">Find Agent</a> <input name="ID" type="hidden"> <input name="Employee_Name" type="hidden"> <input name="Submit" type="submit"> </form> The pop up Div has a Mysql query thats search for available agents that cover the postcode entered in postcode textarea, at the moment the only way I can get this work is by having another submit button which submits the postcode and to the same page. Is there a way use what is entered in the postcode textarea as a php variable without doing a page submit first?? Thanks in advance Tom I have a form on our website that a user can fill out for custom product. I want the form data to be 1) stored into a mysql database AND after storing said data, 2) email the same data to our sales department. 1) The form data DOES get stored into mysql database (except for the first two fields, for some weird reason) 2) I added a "mail" section to the php file that stores the data into the database, but it is not working correctly. I have stripped the email portion down to sending just one of the fields in the "message" to make it easier for troubleshooting I have included here, both the form section of the html file, and the formdata.php file that processes the data for your analysis. I am relatively new to php so there are going to be some issues with security, but I can work on those after I get the store & email process to work correctly. Please review my code and see if anyone can be of assistance. I looked through the forums and couldn't find another issue that was the same as mine. If I just overlooked, please tell me the thread post #. Thanks THE FORM WHICH COLLECTS THE DATA ******************************* <form method=POST action=formdata.php> <table width="640" border=0 align="center"> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=FName size=25></td> <td><div align="right"><b>Telephone</b></div></td> <td><input type=text name=Tel size=25></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=LName size=25></td> <td><div align="right"><b>Fax</b></div></td> <td><input type=text name=Fax size=25></td> </tr> <tr> <td align=right><b>Title</b></td> <td><input type=text name=Title size=25></td> <td><div align="right"><b>Email</b></div></td> <td><input type=text name=Email size=50></td> </tr> <tr> <td align=right><b>Company</b></td> <td><input type=text name=Comp size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Address</b></td> <td><input type=text name=Addr size=25></td> <td><div align="right"><b>Estimated Annual Volume</b></div></td> <td><input type=text name=EAV size=25></td> </tr> <tr> <td align=right><b>City</b></td> <td><input type=text name=City size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>State/Province</b></td> <td><input type=text name=SProv size=25></td> <td><div align="right"><b>Application</b></div></td> <td><input type=text name=Appl size=25></td> </tr> <tr> <td align=right><b>Country</b></td> <td><input type=text name=Ctry size=25></td> <td><div align="right"><b>Type of System</b></div></td> <td><input type=text name=Syst size=25></td> </tr> <tr> <td align=right><b>Zip/Postal Code</b></td> <td><input type=text name=ZPC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td><div align="right"><strong><font color="#FFFF00" face="Arial, Helvetica, sans-serif">COIL DESIGN</font></strong></div></td> <td><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PARAMETERS</strong></font></td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Primary Resistance (ohms)</b></td> <td><input type=text name=Pres size=25></td> <td><div align="right"><b>Primary Inductance (mH)</b></div></td> <td><input type=text name=Pind size=25></td> </tr> <tr> <td align=right><b>Secondary Resistance (ohms)</b></td> <td><input type=text name=Sres size=25></td> <td><div align="right"><b>Secondary Inductance (H)</b></div></td> <td><input type=text name=Sind size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Peak Operating Current (Amps)</b></td> <td><input type=text name=POC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Output Energy (mJ)</b></td> <td><input type=text name=Egy size=25></td> <td><div align="right"><b>Output Voltage (kV)</b></div></td> <td><input type=text name=Volt size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b># HV Towers per Coil</b></td> <td><input type=text name=TPC size=25></td> <td><div align="right"><b># of Coils per Package</b></div></td> <td><input type=text name=CPP size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <th colspan=4><b>Please enter any additional information he </b></th> </tr> <tr> <th colspan=4><textarea name=Mess cols=50 rows=10 id="Message"></textarea></th> </tr> </table> </dl> <div align="center"> <p> <input type=hidden name=BodyTag value="<body bgcolor="#484589" text="#FFFFFF" link="#FFFF00" alink="#FFFFFF" vlink="#FF7F00">"> <input type=hidden name=FA value=SendMail> </p> <p><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PLEASE MAKE SURE ALL INFORMATION<br> IS CORRECT BEFORE SUBMITTING</strong></font></p> <p> <input type=submit value="Submit Form"> </p> </div> </form> THE FILE THAT PROCESSES THE FORM DATA (formdata.php) *********************************************** <?php $con = mysql_connect("localhost","XXX","XXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("customform", $con); $sql="INSERT INTO formdata (Fname, Lname, Title, Comp, Addr, City, SProv, Ctry, ZPC, Tel, Fax, Email, EAV, Appl, Syst, Pres, Pind, Sres, Sind, POC, Egy, Volt, TPC, CPP, Mess) VALUES ('$_POST[Fname]','$_POST[Lname]','$_POST[Title]','$_POST[Comp]','$_POST[Addr]','$_POST[City]','$_POST[SProv]','$_POST[Ctry]','$_POST[ZPC]','$_POST[Tel]','$_POST[Fax]','$_POST[Email]','$_POST[EAV]','$_POST[Appl]','$_POST[Syst]','$_POST[Pres]','$_POST[Pind]','$_POST[Sres]','$_POST[Sind]','$_POST[POC]','$_POST[Egy]','$_POST[Volt]','$_POST[TPC]','$_POST[CPP]','$_POST[Mess]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Your Information Was Successfully Posted"; mysql_close($con); $to = "recipient email address here"; $subject = "Custom Form"; $email = $_POST['Email'] ; $message = $_POST['Comp'] ; $headers = "From: $Email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> |