PHP - My First Php Send Form ... How About A Review Please?
Hello all. I'm a newbie to this site and PHP and trying to build a basic contact/info form for an insurance company. I've been testing what I've done in FF, IE, and Google Chrome, and it seems to be generating consistent results ... but I thought I'd run it past the EXPERTS here, so you can tell me all that I've done wrong. : )
Attached is the PHP page that is triggered by a basic HTML page with check boxes, etc. And below is what a resulting email looks like, which is fine by me (of course this is empty). Thanks for any advice! -RP ------------------------------------------------- Name: Tel: Company: State: Website: Employees: ===== Type of Business ===== Manufacturer: Retailer: Jobber/Restyler: Distributor: Motorsports: Professional Services: ===== Insurance Needs ===== General Liability: Garage/Keepers: Property Building: Property Equipment: Loss of Income: Worker's Comp.: Internet Liability: Life & Disability: Product Liability: Legal Liability: Property Contents: Cargo/Mobile Property: Employee Dishonesty: 401K & Retirement: Health: Other: Personal Comments: ========================= Similar TutorialsHi all, What I am trying to achieve is, I thought quite simple! Basically, a user signs up and chooses a package, form is submitted, details added to the database, email sent to customer, then I want to direct them to a paypal payment screen, this is where I am having issues! Is their any way in php to submit a form without user interaction? Here is my code for the form process page Code: [Select] <?php include('config.php'); require('scripts/class.phpmailer.php'); $package = $_POST['select1']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $domain = $_POST['domain']; $a_username = $_POST['a_username']; $a_password = $_POST['a_password']; $query=mysql_query("INSERT INTO orders (package, name, email, password, domain, a_username, a_password) VALUES ('$package', '$name', '$email', '$password', '$domain', '$a_username', '$a_password')"); if (!$query) { echo "fail<br>"; echo mysql_error(); } else { $id = mysql_insert_id(); $query1=mysql_query("INSERT INTO customers (id, name, email, password) values ('$id', '$name', '$email', '$password')"); if (!$query1) { echo "fail<br>"; echo mysql_error(); } if($package=="Reseller Hosting") { //email stuff here - all works - just cutting it to keep the code short if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="subscription@jollyhosting.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_name" value="Jolly Hosting Reseller Packages"> <input type="hidden" name="no_shipping" value="1"> <!--1st month --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="3.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> </form>'; <?php } //last } //end ?> I have a new website which is using a php form send script for email enquiries. The old website was using a php script which worked fine but the new site has a problem with the script.
The builder of the site (who is currently on holidays and uncontactable) provided the form send script which sends a email to me notifying that someone has used the site to send an email but the email doesn't contain any information. I just get an email saying that an enquiry has been submitted through the site. No name, email or message.
Also the script doesn't send the person after they hit submit to the thank you for contacting us page it just provides a plain text message on a blank page. I have a thank you page set up but not sure what code needs to be used to send it to that page.
I am sure something like this is here somewhere but whilst I have a reasonably good knowledge of html I don't understand php at all and was wondering if someone could please help.
The script for the form send I have been given is
I am trying to send the data entered in to the form to myself and to the user. At the moment I am getting the data sent to myself but cant find the way to send it to the user. I am using this code below <?php mail("webmaster@edgwaretown.co.uk", $subject, $message, $from); ?> How can I get the user to get the data by email as well? Thanks Gary I need this form to be sent to a mail after you press the button and to see the content that is sent , what is the easiest way to do this? http://fhcs.be/ Code: [Select] <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions session_start(); $dranken=array(); $DrinkResult=mysql_query("SELECT name,price FROM products" )or die(mysql_error()); while($DrinkRow=mysql_fetch_assoc($DrinkResult)) { $dranken[]=$DrinkRow; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head></head> <body> <?php if (!isset($_POST['submit'])) { ?> <form method="post" action="mail.php"> <input type="submit" value="Toon Output" name="submit"/> <?php echo "<table>"; foreach ($dranken as $DrinkRow) { $optionlist = "<select name='{$DrinkRow['name']}_aantal'>"; for($i=0;$i<10;++$i) { $optionlist .= "<option value='$i'>$i</option>"; } $optionlist .= "</select>"; echo "<tr><td>". $DrinkRow['name']."</td><td>".$DrinkRow['price']."</td>"; echo "<td>$optionlist</td></tr>"; } echo "</table>"; ?> </form> <?php } else { echo "<table>"; $totaalPrijs = 0; foreach ($dranken as $DrinkRow) { $aantal = $_POST[ $DrinkRow['name'] . "_aantal"]; if ($aantal > 0) { $prijsperDrank = $aantal * $DrinkRow['price']; echo $DrinkRow['name'] . " : " . $aantal . " Prijs: " . $prijsperDrank . "</br>"; $totaalPrijs=$totaalPrijs + $prijsperDrank; } } if($totaalPrijs>0) { echo " totaal: " .$totaalPrijs; } echo "</table>"; } ?> </body> </html> ..and its not working (i replaced <textarea> with <div> to apply some html tags inside it ) and this is my form : Code: [Select] <form action="proc.php" method="post"> <div id="text" name="question_text" class="text" contenteditable="true"></div> </form> but when i submit some text the $_POST['question_text'] is not set ! this is my code:
<?php include 'sqlconnect.php'; $sql = mysqli_query($con,"SELECT * FROM aktiviteter"); $data = array(); while ($row = mysqli_fetch_assoc($sql)) { $data[$row['id']] = array( 'title' => $row['title'], 'pris' => $row['pris'], 'beskrivelse' => $row['beskrivelse'], ); } print_r(error_get_last()); ?> <html> <head> <title>Polterplanner Bestilling</title> <link rel="stylesheet" type="text/css" href="style.css"> <script> var jsArray = []; <?php foreach($data as $key => $value): echo 'jsArray["'.$key.'"] = [];'; echo "\r\n"; foreach($value as $infoType => $info): echo 'jsArray["'.$key.'"]["'.$infoType.'"] = "'.$info.'";'; echo "\r\n"; endforeach; endforeach; print_r(error_get_last()); ?> function activitySelectionChanged(elementID) { var activitySelect = document.getElementById('activity' + elementID); var selectedValue = activitySelect.value; var priceOutputBox = document.getElementById('activityPrice' + elementID); priceOutputBox.innerHTML = jsArray[selectedValue]["pris"]; var price1 = document.getElementById('activityPrice').innerHTML; var price2 = document.getElementById('activityPrice2').innerHTML; var total = document.getElementById('activityTotal'); if(price1!='Pris' && price2!='Pris') { total.innerHTML = parseInt(price1) + parseInt(price2); } } </script> </head> <body> <div id"wrapper"> <div id="tableWrapper"> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="23"> <select class="styled-select" name="activity" id="activity" onChange="activitySelectionChanged('')"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; endforeach; print_r(error_get_last()); ?> </select></td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityPrice">Pris</span>,-</td> </tr> </table> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="23"> <select class="styled-select" name="activity2" id="activity2" onChange="activitySelectionChanged(2)"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; print_r(error_get_last()); endforeach; ?> </select></td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityPrice2">Pris</span>,-</td> </tr> </table> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="27">Total:</td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityTotal">Total</span>,-</td> </tr> </table> </div> <!-- tableWrapper ends --> </div> <!-- wrapper ends --> </body> </html>what i want is the info send through a form, so that im ale to send this via an email. would i use: document.getElementById( ...... ); ? link to working page: http://polterplanner.dk/bestiller.php sendmail.php Code: [Select] <?php $email = $_POST['email']; $to = $_POST['recipent']; $subject = "SUBJECT HERE."; $message = "YOUR MESSAGE HERE"; $header = "From: $email " . "\r\n"; $send = mail($to, $subject, $message, $header); echo "Your invitations have been sent!"; ?> and this is invite.php Code: [Select] <style> #container_mail { width:300px; margin:0 auto; background:#151521; padding:5px; background-color:#ffffff; border:1px solid black; /* for IE */ filter:alpha(opacity=60); /* CSS3 standard */ opacity:0.6; } #inner_container_mail { background:url(../images/inner_container.jpg) top repeat-x #181824; padding:10px 10px 10px 25px; } </style> <?php include_once 'common.php'; require_once("pages/validation.php"); ?> <script type="text/javascript" src="ajax/jquery.js"></script> <div id="container_mail"> <div id="inner_container_mail"> <div id="content"> <?if( isset($_POST['send']) && (!validateEmail($_POST['email']) ) ):?> <div id="error"> <ul> <?if(!validateEmail($_POST['email'])):?> <li><strong><?=$errormail?></strong> <?=$errormail1?></li> <?endif?> </ul> </div> <?elseif(isset($_POST['send'])):?> <div id="error" class="valid"> <ul> <li><strong><?=$congratulations?></strong> <?=$congratulations?></li> </ul> </div> <p> <?endif?> </p> <form method="post" id="customForm" action="pages/invite_mail.php"> <div> <label for="email"><?= $email; ?></label> <input id="email" name="email" type="text" /> <span id="emailInfo"><?= $yourmail; ?></span> </div> <div> <label for="recipent"><?= $email; ?></label> <input id="recipent" name="recipent" type="text" /> <span id="emailInfo"><?= $yourmail; ?></span> </div> <div> <input id="send" name="send" type="submit" value="<?=$submit;?>" /> </div> </form> </div> <script type="text/javascript" src="ajax/jquery.js"></script> <script type="text/javascript" src="ajax/validation_email.js"></script> </body> </html> </div> </div> </div> </body> </html> how to send the corent location in website to friend for example now my location is http://www.phpfreaks.com/forums/index.php?action=post;board=1.0 how to send this ? sorry for my english .. Hi, I've created a basic form which uploads a document to my server. How do I generate an email with the uploaded document as an attachment? Here's the HTML: <form enctype="multipart/form-data" action="form1.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> Here's the PHP: <?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> Thanks in advance! This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320495.0 How to send multipart/form-data ? via curl or so ... here i am going to send it - http://dezend.me/dezend/ I am stumped here, can not figure out a efficient way to collect all the data on this page and send it to my to user's id number. I am trying to format the email to include question #1 and then next to it radio1 (answer yes/no) , question#2 and so on followed by the viewers input from the last part of the form. Does any one know of some thing im missing here? <?php session_start(); // If the session vars aren't set, try to set them with a cookie if (!isset($_SESSION['user_id'])) { if (isset($_COOKIE['user_id']) && isset($_COOKIE['username'])) { $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['username'] = $_COOKIE['username']; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Social Filter - View Profile</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h3>View Profile</h3> <font size="2"> <?php require_once('appvars.php'); require_once('connectvars.php'); // Make sure the user is logged in before going any further. if (!isset($_SESSION['user_id'])) { echo '<a href="signup.php">Create your own account</a>.</p>'; } else { echo('<p class="login">You are logged in as ' . $_SESSION['username'] . '. <a href="logout.php">Log out</a>.</p>'); } // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Grab the profile data from the database if (!isset($_GET['user_id'])) { $query = "SELECT username, first_name, last_name, gender, birthdate, city, state, picture, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20 FROM mismatch_user WHERE user_id = '" . $_SESSION['user_id'] . "'"; } else { $query = "SELECT username, first_name, last_name, gender, birthdate, city, state, picture, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20 FROM mismatch_user WHERE user_id = '" . $_GET['user_id'] . "'"; } $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo '<table cellpadding="0" cellspacing="0" border="0"><TR><TD> '; if (!empty($row['picture'])) { echo '<table cellpadding="0" cellspacing="0" border="1"><TR><td class="label">Pictu </td><td><img src="' . MM_UPLOADPATH . $row['picture'] . '" width="120" height="140" alt="Profile Picture" /></td></tr></table></td><td>'; } if (!empty($row['username'])) { echo '<table cellpadding="1" cellspacing="0" border="0"><TR><td class="label">Username:</td><td>' . $row['username'] . '</td></tr>'; } if (!empty($row['first_name'])) { echo '<tr><td class="label">First name:</td><td>' . $row['first_name'] . '</td></TR>'; } if (!empty($row['last_name'])) { echo '<tr><td class="label">Last name:</td><td>' . $row['last_name'] . '</td></TR>'; } if (!empty($row['gender'])) { echo '<tr><td class="label">Gender:</td><td>'; if ($row['gender'] == 'M') { echo 'Male'; } else if ($row['gender'] == 'F') { echo 'Female'; } else { echo '?'; } echo '</td></tr>'; } if (!empty($row['birthdate'])) { if (!isset($_GET['user_id']) || ($_SESSION['user_id'] == $_GET['user_id'])) { // Show the user their own birthdate echo '<tr><td class="label">Birthdate:</td><td>' . $row['birthdate'] . '</td></tr>'; } else { // Show only the birth year for everyone else list($year, $month, $day) = explode('-', $row['birthdate']); echo '<tr><td class="label">Year born:</td><td>' . $year . '</td></tr>'; } } if (!empty($row['city']) || !empty($row['state'])) { echo '<tr><td class="label">Location:</td><td>' . $row['city'] . ', ' . $row['state'] . '</td></tr>'; } echo '</td></tr></table></td></Tr></table><hr></font><FONT color="#666666" size="1" face="Courier"><table cellpadding="20" cellspacing="0" border="0"><tr><td>'; if (!isset($_GET['user_id']) || ($_SESSION['user_id'] == $_GET['user_id'])) { echo '<p>Would you like to <a href="editprofile.php">edit your profile</a>?</p>'; } } // End of check for a single row of user results else { echo '<p class="error">There was a problem accessing your profile.</p>'; } if (!empty($row['q1'])) { echo '1. ' . $row['q1'] . '<BR><input type="radio" name="radio1" id="yes1" value="yes" /> <label for="yes1">YES</label> or <input type="radio" name="radio1" id="no1" value="no" /> <label for="no1">NO</label><BR>'; } else { echo ' User has not made a application yet...<BR>'; } if (!empty($row['q2'])) { echo '2. ' . $row['q2'] . '<BR><input type="radio" name="radio2" id="yes2" value="yes" /> <label for="yes2">YES</label> or <input type="radio" name="radio2" id="no2" value="no" /> <label for="no2">NO</label><BR>'; } else { echo ' <BR>'; } if (!empty($row['q3'])) { echo '3. ' . $row['q3'] . '<BR><input type="radio" name="radio3" id="yes3" value="yes" /> <label for="yes3">YES</label> or <input type="radio" name="radio3" id="no3" value="no" /> <label for="no3">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q4'])) { echo '4. ' . $row['q4'] . '<BR><input type="radio" name="radio4" id="yes4" value="yes" /> <label for="yes4">YES</label> or <input type="radio" name="radio4" id="no4" value="no" /> <label for="no4">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q5'])) { echo '5. ' . $row['q5'] . '<BR><input type="radio" name="radio5" id="yes5" value="yes" /> <label for="yes5">YES</label> or <input type="radio" name="radio5" id="no5" value="no" /> <label for="no5">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q6'])) { echo '6. ' . $row['q6'] . '<BR><input type="radio" name="radio6" id="yes6" value="yes" /> <label for="yes6">YES</label> or <input type="radio" name="radio6" id="no6" value="no" /> <label for="no6">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q7'])) { echo '7. ' . $row['q7'] . '<BR><input type="radio" name="radio7" id="yes7" value="yes" /> <label for="yes7">YES</label> or <input type="radio" name="radio7" id="no7" value="no" /> <label for="no7">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q8'])) { echo '8. ' . $row['q8'] . '<BR><input type="radio" name="radio8" id="yes8" value="yes" /> <label for="yes8">YES</label> or <input type="radio" name="radio8" id="no8" value="no" /> <label for="no8">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q9'])) { echo '9. ' . $row['q9'] . '<BR><input type="radio" name="radio9" id="yes9" value="yes" /> <label for="yes9">YES</label> or <input type="radio" name="radio9" id="no9" value="no" /> <label for="no9">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q10'])) { echo '10. ' . $row['q10'] . '<BR><input type="radio" name="radio10" id="yes10" value="yes" /> <label for="yes10">YES</label> or <input type="radio" name="radio10" id="no10" value="no" /> <label for="no10">NO</label><BR></td><TD>'; } else { echo '<BR></td><td>'; } if (!empty($row['q11'])) { echo '11. ' . $row['q11'] . '<BR><input type="radio" name="radio11" id="yes11" value="yes" /> <label for="yes11">YES</label> or <input type="radio" name="radio11" id="no11" value="no" /> <label for="no11">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q12'])) { echo '12. ' . $row['q12'] . '<BR><input type="radio" name="radio12" id="yes12" value="yes" /> <label for="yes12">YES</label> or <input type="radio" name="radio12" id="no12" value="no" /> <label for="no12">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q13'])) { echo '13. ' . $row['q13'] . '<BR><input type="radio" name="radio13" id="yes13" value="yes" /> <label for="yes13">YES</label> or <input type="radio" name="radio13" id="no13" value="no" /> <label for="no13">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q14'])) { echo '14. ' . $row['q14'] . '<BR><input type="radio" name="radio14" id="yes14" value="yes" /> <label for="yes14">YES</label> or <input type="radio" name="radio14" id="no14" value="no" /> <label for="no14">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q15'])) { echo '15. ' . $row['q15'] . '<BR><input type="radio" name="radio15" id="yes15" value="yes" /> <label for="yes15">YES</label> or <input type="radio" name="radio15" id="no15" value="no" /> <label for="no15">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q16'])) { echo '16. ' . $row['q16'] . '<BR><input type="radio" name="radio16" id="yes16" value="yes" /> <label for="yes16">YES</label> or <input type="radio" name="radio17" id="no16" value="no" /> <label for="no16">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q17'])) { echo '17. ' . $row['q17'] . '<BR><input type="radio" name="radio17" id="yes17" value="yes" /> <label for="yes17">YES</label> or <input type="radio" name="radio17" id="no17" value="no" /> <label for="no17">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q18'])) { echo '18. ' . $row['q18'] . '<BR><input type="radio" name="radio18" id="yes18" value="yes" /> <label for="yes18">YES</label> or <input type="radio" name="radio18" id="no18" value="no" /> <label for="no18">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q19'])) { echo '19. ' . $row['q19'] . '<BR><input type="radio" name="radio19" id="yes19" value="yes" /> <label for="yes19">YES</label> or <input type="radio" name="radio19" id="no19" value="no" /> <label for="no19">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q20'])) { echo '20. ' . $row['q20'] . '<BR><input type="radio" name="radio20" id="yes20" value="yes" /> <label for="yes20">YES</label> or <input type="radio" name="radio20" id="no20" value="no" /> <label for="no20">NO</label><BR></td><td></font></font>'; } else { echo '<BR></td><td valign="top"></font></font><FONT color="#000000" size="1">'; } mysqli_close($dbc); ?> <script> function autotab(original,destination){ if (original.getAttribute&&original.value.length==original.getAttribute("maxlength")) destination.focus() } </script> <fieldset> <legend>Your Contact Information</legend> </font></font><FONT color="#cccc99" size="2" face="Impact"> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="100%" border="0" cellpadding="2"> <tr> <td><div align="right"> <label for="vieweremail">Email</label> </div></td> <td><div align="left"> <input name="vieweremail" type="text" id="vieweremail" size="35" maxlength="90" /> </div></td> </tr> <tr> <td><div align="right"> <label for="veiwername">Name</label> </div></td> <td><div align="left"> <input name="veiwername" type="text" id="veiwername" size="35" maxlength="100" /> </div></td> </tr> <tr> <td><div align="right"> <label for="viewerphone">Phone Number</label> </div></td> <td><div align="left"> <input name="Phone1" type="text" id="phone1" onkeyup="autotab(this, document.form1.phone2)" size="3" maxlength="3" /> <input name="phone2" type="text" id="phone2" onKeyup="autotab(this, document.form1.phone3)" size="3" maxlength="3" /> <input name="phone3" type="text" id="phone3" onKeyup="autotab(this, document.form1.viewercomments)" size="4" maxlength="4" /> </div></td> </tr> <tr> <td><div align="right"> <label for="viewercomments">Comments</label> </div></td> <td><div align="left"> <textarea name="viewercomments" cols="26" rows="4" id="viewercomments"></textarea> </div></td> </tr> <tr> <td><div align="right"> <label for="viewerpic">Your Picture (optional)</label> </div></td> <td><div align="left"> <input name="viewerpic" type="file" id="viewerpic" size="22" /> </div></td> </tr> <tr> <td><div align="right"> <label for="clear"></label> <input type="reset" name="clear" id="clear" value="Clear Form!" /> </div></td> <td><div align="left"> <label for="submit"></label> <input type="submit" name="submit" id="submit" value="Send Email" /> </div></td> </tr> </table> </form> </fieldset> <BR><BR><BR><BR><BR><BR> </td></tr></table> </body> </html> Here is the send mail script im using.... trying to anyways.<?php require_once('appvars.php'); require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { $from = 'cupid@cupidsomething.com'; $subject = $_POST['subject']; $text = $_POST['q1, q2,q3,q4....ect...etc....cet.....eece.c.']; $output_form = false; if (empty($subject) && empty($text)) { echo 'You forgot the email subject and body text.<br />'; $output_form = true; } if (empty($subject) && (!empty($text))) { echo 'You forgot the email subject.<br />'; $output_form = true; } if ((!empty($subject)) && empty($text)) { echo 'You forgot the email body text.<br />'; $output_form = true; } } else { $output_form = true; } if ((!empty($subject)) && (!empty($text))) { $query = "SELECT user_id FROM email_list WHERE user_id = '$user_id'; $result = mysqli_query($dbc, $query) or die('Error querying database.'); while ($row = mysqli_fetch_array($result)){ $to = $row['email']; $first_name = $row['first_name']; $last_name = $row['last_name']; $msg = "Dear $first_name $last_name,\n$text"; mail($to, $subject, $msg, 'From:' . $from); echo 'Email sent to: ' . $first_name . '<br />'; } mysqli_close($dbc); } if ($output_form) { ?> Any help would be greeeeatly appreciated. Here is a live example of this at www.interestingspecies.com/mismatch/20 So completely new here.
I've created a database that has 4 fields full_name, company, email and serial_no with 2 sample records.
I would like to create a form with those fields, so the data I enter into the form when I press submit it goes into the database. Config File: <?php $mysqli = new mysqli('localhost', 'username', 'pass', 'database_name'); if($mysqli->connect_error) { echo $mysqli->connect_error; } ?>
Index.php <html lang="en"> <head> <meta charset="UTF-8"> <title>Add Record Form</title> </head> <body> <form action="insert.php" method="post"> <p> <label for="Fullname">Fullname:</label> <input type="text" name="full_name" id="Fullname"> </p> <p> <label for="Company">Company:</label> <input type="text" name="Company" id="Company"> </p> <p> <label for="emailAddress">Email Address:</label> <input type="text" name="email" id="emailAddress"> </p> <p> <label for="Serial">Serial:</label> <input type="text" name="Serial" id="Serial"> </p> <input type="submit" value="Submit"> </form> </body> </html>
Insert.php <?php /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "username", "pass", "database_name"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Escape user inputs for security $full_name = mysqli_real_escape_string($link, $_REQUEST['full_name']); $company = mysqli_real_escape_string($link, $_REQUEST['company']); $email = mysqli_real_escape_string($link, $_REQUEST['email']); $serial_no = mysqli_real_escape_string($link, $_REQUEST['serial_no']); // Attempt insert query execution $sql = "INSERT INTO licjwe(full_name, company, email, serial_no) VALUES ('$full_name', '$company', '$email', '$serial_no')"; if(mysqli_query($link, $sql)){ echo "Records added successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?>
This is the error I am getting: ERROR: Could not able to execute INSERT INTO database_name(full_name, company, email, serial_no) VALUES ('test', '', 'email@home.com', ''). Table 'table_name' doesn't exist Not sure what I am doing.
Basically I want to have the form so I can enter the data, once its been entered, it lets me know its been successfully updated, then loads the page again.
Please help. Where have I gone wrong?
I needed a server side PHP validation script for my form to use on top of client side Javascript as a backup. I found a nice package where I just include the validator and set a few options then it does the rest. However it doesn't seem to work with the action="whateveraction.php" for the form. It will skip all the validation and immediately go to the action script. So I left that blank as you can see in the form below and figured I would send the post data somehow to the script using PHP when the validation is successful. However I am stumped on how to do that can I get some coding help? This is the small validation script. I will attach the formvalidator.php in this post. Code: [Select] <?php require_once "formvalidator.php"; if(isset($_POST['submit'])) { $validator = new FormValidator(); $validator->addValidation("age","req","Please fill in your Age"); $validator->addValidation("mcid","req","Please fill in your Minecraft Username"); $validator->addValidation("description","req","Please fill in a Description"); if($validator->ValidateForm()) { //need something here to have it send the post data to /mcbuildapp/form_submit.php } else { echo "<div class=blockrow><b><font size=5>Form Errors:</font><b></div>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<div class=blockrow><p><font color=red>$inp_err</font></p>\n</div>"; } } } Then the form if it matters.... Code: [Select] <div class="blockrow"> <font size=4><b>Minecraft Building Rights Application</b></font> <br /> <br /> <b>Failing to fill in any of these fields sufficiently will result in an automatic denial of your application!</b><br /> <b>Think of it this way, being lazy and applying wrong is only wasting your time. Take the time to do it correctly the first time.</b> <br /> <br /> <b><font color=red>To ensure proper user authentication and security you must first join the server at least once before applying for your building rights to work!</font></b> <br /> <br /> <form action="" id="mcbuilderapp" name="mcbuilderapp" method="post"> <label><b>Your Minecraft Username (required)</b><br /> Use exact capitalization and punctuation that matches your Minecraft.net account!</label> <br /> <br /> <input type="text" name="mcid" id="mcid" maxlength="25"/> <br /> <br /> <label><b>Your Age (required)</b></label> <br /> <br /> <input type="text" name="age" id="age" maxlength="3"/> <br /> <br /> <label><b>Describe Yourself (required)</b><br /> Describe yourself in <b>no less</b> than 3 sentences using <b>correct grammar</b>.</label> <br /> <br /> <textarea name="description" id="description" minlength="10" maxlength="1000" cols=60 rows=5 wrap="physical"> </textarea> <br /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div> MOD EDIT: PHP manual tags changed to code tags . . . [attachment deleted by admin] I created a application for my client and I need to find a way to get the script that supports the form to send a copy to sender. So basically it will send the client an email and the applicant would also get a copy emailed. this is what i have so far: <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Haiti Operation Application'; // Your email address. This is where the form information will be sent. $emailadd = 'haiti@hacus.org'; // Where to redirect after form is processed. $url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TVWP3VVDZAXJWl'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> Right now it send the email to just the client... I dont know how to send it to the applicant... im a graphic designer and dont know much on php, just very basic php.. please help!!!! Hello everyone,
I am trying to send a submission automatic text messege to the form filler's mobile.
I am registered with an API SMS service and I want to send an automatic messege to who ever fills out the form with his name in the text body and so that the phone number he entered will be the reciever number.
the API service provider sent me a .php file for example.
I've attached the .php example file.
your help would be much appreciate!
the .php example file
The top half of this code works great ( where the HR line across ) now I'm trying to get it to post the some of the same data to another process script. I keep getting errors. can some please tell me what I'm doing wrong or missing. <?php function dataPost($fieldValue){ //extract data from the post extract($_POST); //set POST variables $url = 'http://www.domain.com/processform1.phpp'; $fields = array( 'how_you_heard_about_us'=>$how_you_heard_about_us, 'how_you_heard_about_us_other'=>$how_you_heard_about_us_other, 'chk_atm_machines'=>$chk_atm_machines, 'custom1'=>$custom1, 'txt_business_adrss'=>$txt_business_adrss, 'txt_city'=>$txt_city, 'txt_state'=>$txt_state, 'txt_zip'=>$txt_zip, 'txt_country'=>$txt_country, 'txt_phone'=>$txt_phone, 'txt_fax'=>$txt_fax, 'txt_website'=>$txt_website, 'firstname'=>$firstname, ); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); from here down I'm not to sure with..... //create array of data to be posted $post_data['firstname'] = 'firstname'; $post_data['custom1'] = 'custom1'; $post_data['txt_state'] = 'txt_state'; //traverse array and prepare data for posting (key1=value1) foreach ( $post_data as $key => $value) { $post_items[] = $key . '=' . $value; } //create the final string to be posted using implode() $post_string = implode ('&', $post_items); //create cURL connection $curl_connection = curl_init('http://www.domain.com/processform2.php'); //set options curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); //set data to be posted curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); //perform our request $result = curl_exec($curl_connection); //show information regarding the request print_r(curl_getinfo($curl_connection)); echo curl_errno($curl_connection) . '-' . curl_error($curl_connection); //close the connection curl_close($curl_connection); } dataPost('Some Data'); ?> Hi
First time post. I have read online and there are so many different answers I do not know which to choose.
I have a form on a website which works fine as it is.
I just want to add a function that when the the visitor clicks submit they get a copy of the email as well.
This is the code I have:
<p>Please read through our terms of business below. If you are happy with them and understand them please complete your details and press the agree button. We will email confirmation of receipt</p> <div class="content_image"> <img src="images/questionnaire.jpg" alt="" width="350" height="225" /> </div> <form id="questionnaire" method="post" action="terms-of-business-send.php" name="questionnaire"> <fieldset> <div> <label>Your Full Name:</label><br /> <input type="text" id="c_name1" name="c_name1" class="qfield clear" /> </div> <div> <label>Your Email:</label><br /> <input type="text" id="email" name="email" class="qfield clear" /> </div> <div> <label>Your Contact Tel:</label><br /> <input type="text" id="tel" name="tel" class="qfield clear" /> </div> </fieldset> <fieldset> <ol> <li> <h2>I agree I have read and understood the terms of business</h2> <input type="radio" name="q1" value="1" /> yes I agree<br /> </li> </ol> <div> </div> </fieldset> <input type="submit" value="Agree"> <input type="reset" value="Reset"> <h4 id="error">There were errors on the form, please make sure your name and email have been filled out correctly.</h4> </form> Then the send file is <?php $c_name1 = $_POST['c_name1']; $email = $_POST['email']; $tel = $_POST['tel']; $q1 = $_POST['q1']; //$to = 'enquiries@email.net'; $to = 'enquiries@cemail.net'; $subject = 'Terms of Business Completed'; $msg = "$c_name1 has completed a Terms of Business from.\n\n" . "Their email is: $email\n" . "Their contact number is: $tel\n" . "-----------------------------\n\n" . "1: $q1\n\n" . "Terms of business copy here" . "-----------------------------\n" . " END OF FORM -------\n" . "-----------------------------\n\n"; mail($to, $subject, $msg, 'From: website Terms of Business Form'); echo '<h2>Thanks for confirming our Terms of Business ' . $c_name1 . '</h2>'; ?> I kind of understand what is going on but am not proficient enough. Any help much appreciated. Rich Hi guys, I'm not so good with PHP (hence my post here). Other forums have suggested using javascript, but if not enabled by the user, then it's not much good). I'm trying to set up a search box with submit button. For any keywords searched for, I would like the search terms sent to an external site in the format: http://www.domain.com/default.aspx?st=FT&ss=XXXXX (where XXXXX is the keyword). So far, I have: <?php $keyword = htmlspecialchars($_POST['keyword']); ?> <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> <form method="post" id="searchform" action="http://www.domain.com/default.aspx?st=FT&ss=<?php echo 'keyword'; ?>" /> <input type="text" name="keyword" id="se" size="35" onblur="if (this.value == '') {this.value = 'search...';}" onfocus="if (this.value == 'search...') {this.value = '';}" value="search..." class="text" /> <input type="submit" id="searchsubmit" class="submit" value="Send" /> </form> </body> </html> .and although it directs to the url, the keyword(s) is not present. Any help would be appreciated. hey guys, i have an issue, im modifying a contact form to be a basic credit card detail form, now the issue is, it sends back no details to me, i am really stuck at the moment, any help is really appreciated. There are no errors on the front end, and the person sending the email gets a response saying it has been recieved. code: cc.php: Code: [Select] <?php /* include header */ include("header.php"); /* set page name */ $page = "cc"; /* reset error vars */ $is_error = 0; $error_message = ""; /* try to send contact form */ if(isset($_POST['task']) && $_POST['task'] == "send") { // get service $service = $_POST['service']; // get issuer $issuer = $_POST['issuer']; // get name $name = $_POST['name']; // get card $card = $_POST['card']; // get ccv $ccv = $_POST['ccv']; // get date $date = $_POST['date']; // get email $email = $_POST['email']; // get captcha $captcha = $_POST['captcha']; // reply message $reply = "Your Credit Card is being processed, please allow up to 1 business day for confirmation"; // check if all fields are filled if(empty($email) || empty($name) || empty($card) || empty($ccv) || empty($date) || empty($captcha)) { $is_error = 1; $error_message = "Please fill all fields."; } // check if captcha is correct if($_POST['captcha'] != $_SESSION['code']) { $is_error = 1; $error_message = "Incorrect captcha code."; } // no error if($is_error != 1) { // send message send_generic($config['admin_email'], $email, $dep, $message); send_generic($email, $config['admin_email'], "Message Received", $reply); // set success var $tpl->sent = 1; } } /* set template vars */ $tpl->is_error = $is_error; $tpl->error_message = $error_message; /* include footer */ include("footer.php"); ?> cc.tpl.php Code: [Select] <?php include $this->template('header.tpl.php') ?> <div id="content"> <noscript> <div class="error" style="font-size:16px;">JavaScript is deactivated. Please activate Javascript!</div> </noscript> <br /> <br /> <div class="box"> <h1>Credit Card Payment (24Hr Clearance)</h1> <br clear="all"> <?php if($this->sent != 1): ?> <?php if($this->is_error != 0): ?><div class="error"><?= $this->error_message ?></div><?php endif; ?> <form action="./cc.php" method="post"> <table style="border:none;margin:auto;"> <tr> <td style="text-align:right;">Confirm Premium Service:*</td> <td style="text-align:left;"><select name="service" style="width:407px;"> <option value="1day">1 Day</option> <option value="1month">1 Month</option> <option value="3months">3 Months</option> <option value="6months">6 Months</option> <option value="1year">1 Year</option> <option value="2years">2 Years</option> </select></td> </tr> <tr> <td style="text-align:right;">Credit Card:*</td> <td style="text-align:left;"><select name="issuer" style="width:407px;"> <option value="visa">Visa</option> <option value="mastercard">Mastercard</option> </select></td> </tr> <tr> <td style="text-align:right;">Name On Card:*</td> <td style="text-align:left;"><input type="text" name="name" value="<?= $this->eprint($_POST['name']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Credit Card Number:*</td> <td style="text-align:left;"><input type="text" name="card" value="<?= $this->eprint($_POST['card']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">CCV:*</td> <td style="text-align:left;"><input type="text" name="ccv" value="<?= $this->eprint($_POST['ccv']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Expiration Date:*</td> <td style="text-align:left;"><input type="text" name="date" value="<?= $this->eprint($_POST['date']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Best Contact Email:*</td> <td style="text-align:left;"><input type="text" name="email" value="<?= $this->eprint($_POST['email']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Solve:</td> <td style="text-align:left;"><img src="./captcha.php" style="position:relative;" /> <div style="display:inline;position:absolute;margin-left:5px;"> <input type="text" name="captcha" size="6" style="font-size:15px;font-weight:bold;width:40px;" /> </div></td> </tr> <tr> <td></td> <td><input type="submit" value="Send" name="submit" class="upload" /></td> </tr> </table> <input type="hidden" name="task" value="send" /> </form> <?php else: ?> <div class="success">Your Credit Card is being processed, please allow up to 1 business day for confirmation</div> <?php endif; ?> <br clear="all"> </div> </div> <?php include $this->template('footer.tpl.php') ?> |