PHP - Help With Emailing Information From A Form
Ok what I am trying to do it make a simple form. Once the user has eneter all the details and clicked submit I want this information to be sent to me in an email.
So far I have got the email sending but i am just having trouble getting the information to be displayed correctly in the email that is sent. For the subject I want first name last name <email>. And then for the main message of the email I want the information from the form to displayed something like the following. First Name : '$fname' Last Name : '$lname' and so on for all the variables i have collected from the online form. Here is what I have got so far and I would appreciate any help you can give me thanks. <?php if ($_SERVER['REQUEST_METHOD']=="POST"){ // Recipent Email $to="andrew@peppermintdigital.com"; $subject="Reply to Peppermint Invitation"; $title = $_POST['title']; $fname = stripslashes($_POST['fname']); $sname = stripslashes($_POST['sname']); $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 = stripslashes($_POST['fname']) ."<".stripslashes($_POST['email']).">"; // Email Message $message = $_POST['postcode']; $body = "hello"; // Validation Begins // Add Erros To Array $errors = array(); // Check Form if (!$_POST['title']) $errors[] = "Title Required"; if (!$_POST['fname']) $errors[] = "Forename Required"; if (!$_POST['sname']) $errors[] = "Surnname 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['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>"; } else { // Build message headers $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; // Build message body // Insert two dashes in front of the MIME boundary when we use it $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Start of attachment $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; // 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 { } ?> Similar TutorialsI have not been able to get my mail form to send messages to my email. The thank you page pops up after I test it, but nothing is sent. I use GoDaddy, so I'm not sure if that is part of the problem. This is my first attempt at PHP, so I don't know what I'm doing! I got the code from the Site Wizard. Any help would be great! Here is the code in my HTLM page for the form: <div id="package"> <fieldset id="personalinfo"> <legend class="perlegend"><img src="Art/header_contact.png" class="perlegendheader" > <div id="collage"></div> </legend> <p> </p> <form action="gdform.php" method="post"> <input type="hidden" name="redirect" value="thankyou.html" /> <p> <label for="name"> Name</label> <br> <input name="name" type="text"/> </p> <p> <label for="email">Email</label> <span class="required">(required)</span><br> <input name="email" type="text"/> </p> <p> <label class="top" for="comments">Message</label> <br> <textarea name="comments" cols="32" rows="5"></textarea> </p> <p> <input name="Submit" type="submit" class="submit" value="SEND"/> </p> </form> <br class="clear" /> </p> </fieldset > <br> </div> Here is my PHP code (without my real email address): <?php // ------------- CONFIGURABLE SECTION ------------------------ $mailto = 'XXX@gmail.com' ; $subject = "Message from Martha Berry Design" ; $formurl = "http://www.marthaberrydesign.com/contact.html" ; $errorurl = "http://www.marthaberrydesign.com/error.html" ; $thankyouurl = "http://www.marthaberrydesign.com/thankyou.html" ; $email_is_required = 1; $name_is_required = 0; $comments_is_required = 0; $uself = 0; $use_envsender = 0; $use_sendmailfrom = 1; $use_webmaster_email_for_from = 0; $use_utf8 = 1; $my_recaptcha_private_key = '' ; // -------------------- END OF CONFIGURABLE SECTION --------------- $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ; if (!isset( $use_envsender )) { $use_envsender = 0 ; } if (isset( $use_sendmailfrom ) && $use_sendmailfrom) { ini_set( 'sendmail_from', $mailto ); } $envsender = "-f$mailto" ; $fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_POST['name'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) { header( "Location: $errorurl" ); exit ; } if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) { header( "Location: $errorurl" ); exit ; } if (strlen( $my_recaptcha_private_key )) { require_once( 'recaptchalib.php' ); $resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] ); if (!$resp->is_valid) { header( "Location: $errorurl" ); exit ; } } if (empty($email)) { $email = $mailto ; } $fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ; if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Name of sender: $fullname\n" . "Email of sender: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; $headers = "From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.0" . $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ; if ($use_envsender) { mail($mailto, $subject, $messageproper, $headers, $envsender ); } else { mail($mailto, $subject, $messageproper, $headers ); } header( "Location: $thankyouurl" ); exit ; ?> Hi everyone, I have created a HTML form for collecting data on a web page, ie, name, email address, etc, which works fine. I have then asked for that data to be emailed to me using the POST action in conjunction with a PHP script called "carparkprocess2.php". At the moment, the form works OK on the web page, the confirmation message to say the data has been submitted successfully works OK, but the email that should display the information entered into the form doesn't work properly. It comes through and is formatted OK, but the form information is missing. I've been trying to resolve this issue for 2 days straight now and have tried loads of different things! Can anybody help? I need a quick answer on this one if possible Code: [Select] <?php error_reporting(E_ALL ^ E_NOTICE); // Prints all errors except Notices. /* Subject and Email Variables */ $emailSubject = 'Car Park Reservation Confirmation'; $webMaster = 'ben@maver.co.uk'; /* Gathering Data Variables */ if (!isset($_POST['name'])) { $_POST['name'] = "name"; } if (!isset($_POST['carregistration'])) { $_POST['carregistration'] = "carregistration"; } if (!isset($_POST['emailaddress'])) { $_POST['emailaddress'] = "emailaddress"; } if (!isset($_POST['numberinparty'])) { $_POST['numberinparty'] = "numberinparty"; } $body = <<<EOD <br><hr><br> Name: $name <br> Vehicle Registration: $carregistration <br> Email Address: $emailaddress <br> Number in Party: $numberinparty <br> EOD; $mailheaders .= "From: $emailaddress\r\n"; $headers .= "Content-type: text/html"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>Car Park Reservation Confirmation</title> <meta http-equiv='Content-Type' content='text/html'> <style type='text/css'> <!-- body { min-height: 100%; height: auto; background: #000000; color: #ffffff; font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif; margin: 0; } --> </style> </head> <div> <div align='left'>Your car park reservation request has been successful</div> </div> </body> </html> EOD; echo "$theResults"; ?> Here is the HTML within the form: Code: [Select] <form method='post' action='carparkprocess2.php'> Hi all, I have a simple script that does not work! I think it may be to do with $num = mysqli_num_rows($result) and $row = mysqli_assoc_result($result). I have tried echoing the value which works if I put it above the include("cxn.php");. The code is: <?php include("cxn.php"); $sql = "SELECT * FROM table WHERE email='$_POST[email]'"; $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); $num = mysqli_num_rows($result); $row = mysqli_fetch_assoc($result); if ($num > 0) { $to = "$_POST[email]"; $subj = "from the website"; $mess = "Your value is".$row['value']; $mailsend = mail($to,$subj,$mess,$headers); echo "email sent to $_POST['email']"; } else { echo "email not found!";} ?> Hi - I'm trying to speed up part of my business. I sell photos taken on site...I dump said photos in a directory and my little app pulls all images from a given directory and displays them on a page. I can get the filename etc displayed on screen, added to the image attributes, whatever. I'd like to have a checkbox next to each image, and the user checks a few and it'll send an email to me so I can fill their order. Looks like this: http://www.limitedwave.com/reflex/ I can use a sendmail like I've tried, but it can take like 10 minutes to actually send from the server which is lame. I'd be cool with just dropping the data in my database, then retrieving selections by user's name, but I don't know how to set up a form/insert page that will insert from a somewhat random set of checkboxes. Thoughts? Thanks. here's my html form: <form action="contact2.php" method="post" target="_self" id="contactform"> <ol> <li> <label for="name2">Your Name <span class="red">*</span></label> <input id="name2" name="name2" class="text" /> </li> <li> <label for="youremail">Your email <span class="red">*</span></label> <input id="youremail" name="youremail" class="text" /> </li> <li> <label for="company2">Company</label> <input id="company2" name="company2" class="text" /> </li> <li> <label for="subject2">Subject</label> <input id="subject2" name="subject2" class="text" /> </li> <li> <label for="message2">Message <span class="red">*</span></label> <textarea id="message2" name="message2" rows="6" cols="50"></textarea> </li> <li class="buttons"> <input type="image" name="imageField" id="imageField" src="images/send.gif" /> </li> </ol> </form> Here's my php code: <?PHP global $_POST; $name = $_POST["name2"]; $youremail = $_POST["youremail"]; $company = $_POST["company2"]; $subject = $_POST["subject2"]; $message = $_POST["message2"]; $to = "ldemotts@market-johnson.com"; $subject = "Form Submission"; $headers = "From: $youremail\n"; $message = "A visitor to your site has filled out the following information.\n Name: $name2 Email Address: $youremail Company: $company2 Subject: $subject2 Message: $message2"; if (preg_match(' /[\r\n,;\'"]/ ', $_POST['youremail'])) { exit('Invalid Email Address'); } else { mail($to,$subject,$message,$headers); } ?> Hi Guys, I need a bit of help. I need to post a value to a second page, but I want the button to have the same name. The page is to show registered users and then allows a user to send a friend request 'to put it in simple terms'. Username submitbutton username submitbutton And then i do the following <?php foreach ($_POST['username') as $user { echo $user; } ?> How could i go about doing this or would I have to use a 'Hidden' Field. I am writing an email form for my site with some simple validation. I have the error messages working just fine. They do what they are supposed to do. However, when the form is brought back up to have the errors fixed. It puts a "1" in the field box. I looked at the code and I do not see where the "1" is coming from. I am also in the process of trying to figure out how to send email through my mail account using smtp. I want to see if it is going to send me the information that I ask for or the "1". Currently all of my work is being done on my localhost server Here is the code that I am using Code: [Select] <?php $email_form = "<form action='' target='' id='contactform' method='post'>\n"; $email_form .="<p class='form_header'>Contact us</p>\n"; $email_form .= "<fieldset>\n"; $email_form .= "<P>\n"; $email_form .= "<label for='name'><em>*</em> Your Name:</label>\n"; $email_form .= "<input type='text' name='name' id='name' value=".(isset($_POST['name']))." />\n"; $email_form .= "</p>\n"; $email_form .= "<p>\n"; $email_form .= "<label for='email'><em>*</em> E-mail:</label>\n"; $email_form .= "<input type='text' name='email' id='email' value=".(isset($_POST['email']))." />\n"; $email_form .= "</p>\n"; $email_form .= "<p>\n"; $email_form .= "<label for='subject'>Subject:</label>\n"; $email_form .= "<input type='text' name='subject' id='subject' value=".(isset($_POST['subject']))." />\n"; $email_form .= "</p>\n"; $email_form .= "<p>\n"; $email_form .= "<label for='message'><em>*</em> Message:</label>\n"; $email_form .= "<textarea name='message' id='message'>".(isset($_POST['message']))."</textarea>\n"; $email_form .= "</p>\n"; $email_form .= "<input type='submit' id='submit' value='Submit!' name='submitted' /><br />\n"; $email_form .= "<p class='required'>Fields marked with an asterik(*) are required</p>\n"; $email_form .= "</fieldset>\n"; if (!isset($_POST['submitted'])) { echo "$email_form"; } else { $name = (isset($_POST['name'])); $email = (isset($_POST['email'])); $to = "your@email.co.uk"; $subject = (isset($_POST['subject'])); $body = (isset($_POST['message'])); if ($subject == "") { $subject = "Email from website"; } else { $subject == $subject; } if ($_POST['name'] != "") { $_POST['name'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING); if ($_POST['name'] == "") { $errors .= 'Please enter a valid name.<br/><br/>'; } } else { $errors .= 'Please enter your name.<br/>'; } if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= "$email is <strong>NOT</strong> a valid email address.<br/>"; } } else { $errors .= 'Please enter your email address.<br/>'; } if ($_POST['message'] != "") { $_POST['message'] = filter_var($_POST['message'], FILTER_SANITIZE_STRING); if ($_POST['message'] == "") { $errors .= 'Please enter a message to send.<br/>'; } } else { $errors .= 'Please enter a message to send.<br/>'; } if (empty($errors)) { $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: " . $email . "\r\n"; $success = mail($to, $subject, $body, $headers); } if ($success) { echo "<p>The following email has been sent</p>\n"; echo "<p>Name: $name</p>\n"; echo "<p>E-mail: $email</p>"; echo "<p>Subject: $subject</p>\n"; echo "<p><em>*</em> Message: $body</p>\n"; echo "<p>While you are waiting for a response from one of our staff members. Feel free to look at some of the following sections</p>\n"; echo "<a href='../waiting.php'>In The Mail</a>"; echo "Thank you for visiting Michael48060.</p>\n"; } else echo "$email_form"; } if (!empty($errors)) { echo "<div class='error_div'> <span class='errors'>" . $errors . "</span> </div>"; } ?> Below are two pages...Post.php. and Posted.php the posted page checks and makes sure everything is filled out and makes sure that the link has not been already added. The problem I am having is that it is not pulling over the link information. Every time you hit submit it drops down and goes to saying that you forgot to fill something in and I have it showing everything right now so when that happens I can see what is not going through and the $link never comes through. Any ideas? if anyone needs a better explanation please post and I will try to explain better....basically I am trying to post and everything posts but the link. POST.PHP Code: [Select] <h1>Post</h1> <div class="descr"></div><form method="post" action="posted.php"> <table align="center"> <tr> <td> Youtube Embed Link </td> <td> <input name="link" type="text" id="link"/> </td> </tr> <tr> <td> Title Of Song </td> <td> <input name="title" type="text" id="title" /> </td> </tr> <tr> <td> Author </td> <td> <input name="author" type="text" id="author" /> </td> </tr> <tr> <td> Text: </td> <td> <input name="information" type="text" id="information" /> <br /> </td> </tr> <tr> <td colspan="2" align="center"> <br> <input name="submit" type="submit" value="Post" /> </td> </tr> </table> </form> POSTED.PHP Code: [Select] <?php //msut be logged in page session_start(); if ($_SESSION['username']) { echo""; } else die("You must log in first!"); //form information $submit = $_POST['submit']; $row4 = $_SESSION['username']; // form data $link = strip_tags($_POST['link']); $information = strip_tags($_POST['information']); $title = strip_tags($_POST['title']); $author = strip_tags($_POST['author']); $date = date('Y-m-d'); //Connect To Database $hostname=''; $username2=''; $password2=''; $dbname=''; mysql_connect($hostname,$username2, $password2) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); $querycheck = "SELECT * FROM videos WHERE username='$row4'"; $result = mysql_query($querycheck); while($rowz = mysql_fetch_array($result)) $linkcheck = $rowz['link']; if ($submit) { if ($link&&$information&&$title&&$author) { if ($link == $linkcheck) { die ("This link has already been posted."); } else { //Connect To Database $hostname=''; $username2=''; $password2=''; $dbname=''; mysql_connect($hostname,$username2, $password2) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); $queryreg = mysql_query("INSERT INTO videos Values ('','$row4','$link','$title','$author','$information','$date')"); } } else { die ("You forgot to put something in the link/title/author/text box. $information $title $link $author"); } } ?> Have never done this before, but I'm sure many of you have. What I am trying to do is take the information that the user fills out in this form and when they hit submit, it will be displayed into a html table on the next page. I don't need someone to do the entire table for me, just looking for some help to get started and a general idea of what to do. Here is my code for my form that I have created... Code: [Select] <!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"> <head> <title>Lab 4</title> </head> <body> <?php ?> <form method="POST" action="lab4form.php"> <label for="first_name">First Name:</label> <input type="text" id="first_name" name="first_name" /><br /> <label for="last_name">Last Name:</label> <input type="text" id="last_name" name="last_name" /><br /> <label for="coverage_amount">Coverage Amount:</label> <input type="text" id="coverage_amount" name="coverage_amount" /><br /> <label for="gender">Gender:</label> <br> <input id="male" type="radio" value="radiobutton" name="male" /> <label for="male">Male</label> <input id="female" type="radio" value="radiobutton" name="female" /> <label for="female">Female</label> <br /> <br> <label for="Age">Age:</label> <input type="text" id="age" name="age" /><br /> <br> <label for="health">Health Conditions</label> <br /> <input type="checkbox" name="health" value="heart" /> <label for="health">Heart Disease</label><br /> <input type="checkbox" name="health" value="diabetes" /> <label for="health">Diabetes</label><br /> <input type="checkbox" name="health" value="blood" /> <label for="health">High Blood Pressure</label><br /> <input type="checkbox" name="health" value="Smoker" /> <label for="health">Smoker</label><br /> <input type="checkbox" name="health" value="lung" /> <label for="health">Lung disease</label><br /> <FORM METHOD=POST ACTION="lab4form.php"> <P>Employment Status<BR> <SELECT NAME="employment"> <OPTION VALUE="lab4form.php">Unemployed <OPTION VALUE="lab4form.php">Full-Time <OPTION VALUE="lab4form.php">Part-Time <OPTION VALUE="lab4form.php">Student </SELECT><br /> <br> <label for="comments">Comments</label> <input type="text" id="comments" name="comments"/><br /> <br> <input type="submit" value="Add User" name="btn_add" /> </form> </body> </html> hi everyone, Im trying to make a checkout page, where if the user is logged in, the address information is called from the database and fills the form automatically, my problem is i don't know how to fill the php variables with the result of my sql query..sorry to be a complete noob but can someone explain how i would do this? <?php if (!defined('WEB_ROOT') || !isset($_GET['step']) || (int)$_GET['step'] != 1) { exit; } require_once 'loginfunctions.php'; checkCustomerLogin(); $errorMessage = ' '; ?> <?php // get the customer id from the session. $cu_id = $_SESSION['cu_id'] ?> <?php //connect to server $mysqli = mysqli_connect("localhost", "root", "", "onlinestore"); //get default shipping and payment address $mysql = "SELECT cu_id,od_shipping_first_name,od_shipping_last_name,od_shipping_address1,od_shipping_address2,od_shipping_phone,od_shipping_city,od_shipping_state,od_shipping_postal_code FROM tbl_customer WHERE $cu_id = cu_id"; $result = mysqli_query($mysql,$mysqli); $row = mysql_fetch_assoc($result); //populate form with values ? $txtShippingFirstName = 'test'; $txtShippingLastName = 'test'; $txtShippingAddress1 = 'test'; $txtShippingAddress2 = 'test'; $txtShippingPhone = 'test'; $txtShippingState = 'test'; $txtShippingCity = 'test'; $txtShippingPostalCode = 'test'; ?> <script language="JavaScript" type="text/javascript" src="library/checkout.js"></script> <table width="550" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td>Step 1 Of 3 : Please Confirm Shipping And Payment Information </td> </tr> </table> <p id="errorMessage"><?php echo $errorMessage; ?></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=2" method="post" name="frmCheckout" id="frmCheckout" onSubmit="return checkShippingAndPaymentInfo();"> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td colspan="2">Shipping Information</td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtShippingFirstName" type="text" class="box" id="txtShippingFirstName" value="<?php echo $txtShippingFirstName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtShippingLastName" type="text" class="box" id="txtShippingLastName" value="<?php echo $txtShippingLastName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtShippingAddress1" type="text" class="box" id="txtShippingAddress1" value="<?php echo $txtShippingAddress1 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtShippingAddress2" type="text" class="box" id="txtShippingAddress2" value="<?php echo $txtShippingAddress2 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtShippingPhone" type="text" class="box" id="txtShippingPhone" value="<?php echo $txtShippingPhone ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtShippingState" type="text" class="box" id="txtShippingState" value="<?php echo $txtShippingState ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtShippingCity" type="text" class="box" id="txtShippingCity" value="<?php echo $txtShippingCity ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtShippingPostalCode" type="text" class="box" id="txtShippingPostalCode" value="<?php echo $txtShippingPostalCode ?>" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td width="150">Payment Information</td> <td><input type="checkbox" name="chkSame" id="chkSame" value="checkbox" onClick="setPaymentInfo(this.checked);"> <label for="chkSame" style="cursor:pointer">Same as shipping information</label></td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtPaymentFirstName" type="text" class="box" id="txtPaymentFirstName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtPaymentLastName" type="text" class="box" id="txtPaymentLastName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtPaymentAddress1" type="text" class="box" id="txtPaymentAddress1" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtPaymentAddress2" type="text" class="box" id="txtPaymentAddress2" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtPaymentPhone" type="text" class="box" id="txtPaymentPhone" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtPaymentState" type="text" class="box" id="txtPaymentState" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtPaymentCity" type="text" class="box" id="txtPaymentCity" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtPaymentPostalCode" type="text" class="box" id="txtPaymentPostalCode" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr> <td width="150" class="entryTableHeader">Payment Method </td> <td class="content"> <input name="optPayment" type="radio" id="optPaypal" value="paypal" checked="checked" /> <label for="optPaypal" style="cursor:pointer">Paypal</label> <input name="optPayment" type="radio" value="cod" id="optCod" /> <label for="optCod" style="cursor:pointer">Cash on Delivery</label></td> </tr> </table> <p> </p> <p align="center"> <input class="box" name="btnStep1" type="submit" id="btnStep1" value="Proceed >>"> </p> </form> On an HTML Form, I have several Text boxes called "base1, base2...base13" Another text box I have is called "base_quantity" In my PHP routine: This is part of my code: Code: [Select] $selected_base = $_POST['base1']; if ($selected_base == 'yes') { $base_value = $base_value + 1; $base_status = 'Yes'; } else if ($selected_base == 'no') { $base_value = $base_value - 1; $base_status = 'No'; }Later on in the PHP routine I want to pass back to the Form the value of $base_status and place it in the "base_quantity" text box. Something like this: base_quantity = $base_value. Can someone tell me how information is passed back to the FORM. Thank You, Sam I have a question regarding my email form submission. The email seems to work fine, but the recipient of the email can view my server information (see attached image for example) there are many website hosted on my server and i would like to hide the server info on form submissions. does anyone know of a way to do this? thanks Hey everyone, I don't know what i'm doing wrong or missing some code snippet (duh! thats why i'm here. lol). The html form with meeting time doesn't transfer the information over to my calendar php file. calendar.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Lab 5</title> <link rel="stylesheet" type="text/css" href="settings.css" /> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> </head> <body> <center> <form method="get" action="calendar.php"> Student Name: <input type="text" name="name"/> <input type="submit" value="Submit" /> <input type="reset" value="Clear" /> </center> <p align="center">Today is <?php print(date("l, F\ jS\ Y")); ?> </p> <?php $date = time(); $day = date('d', $date); $month = date('m', $date); $year = date('Y', $date); $first_day = mktime(0,0,0,$month, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } $days_in_month = cal_days_in_month(0, $month, $year); //Table starts here echo "<table border=1 cellpadding=10 align=center height=500 width=494>"; echo "<tr><th colspan=7> $title $year </th></tr>"; echo "<tr><td width=42>Su</td> <td width=42>Mo</td> <td width=42>Tu</td> <td width=42>We</td> <td width=42>Th</td> <td width=42>Fr</td> <td width=42>Sa</td></tr>"; //Days in week $day_count = 1; echo "<tr>"; // blank days while ( $blank > 0 ) { echo "<td></td>"; $blank = $blank-1; $day_count++; } //Set the first day of the month $day_num = 1; //This while loops works while there are still days in that month while ( $day_num <= $days_in_month ) { echo "<td> $day_num </td>"; $day_num++; $day_count++; //Starts new row for every week if ($day_count > 7) { echo "</tr><tr>"; $day_count = 1; } } //Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ) { echo "<td> </td>"; $day_count++; } echo "</tr></table>"; ?> <a href="http://helios.ite.gmu.edu/~easad/IT207/Lab5/DecCal.php" target="info">Next Month</a> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a> </p> </body> </html> MeetingTime.html Code: [Select] <!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="settings.css" /> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <title>Meeting Time Sign Up</title> </head> <body> <h1> Meeting Time Setup Form</h1> <form method="get" action="calendar.php"> <table border="1" cellpadding="15" width="75%"> <tr><td width=42>Day: </td> <td width=42><input type="checkbox" name="available" value="Mon" />Monday</td> <td width=42 ><input type="checkbox" name="available" value="Tue" />Tuesday</td> <td width=42 ><input type="checkbox" name="available" value="Wed" />Wednesday</td> <td width=42 ><input type="checkbox" name="available" value="Thr" />Thrusday</td> <td width=42 ><input type="checkbox" name="available" value="Fri" />Friday</td></tr> <tr><td width=42 >Time: </td> <td width=42 > <p><select multiple="multiple" size="3" style="width: 180%;"> <option>7:00am</option> <option>7:00am</option> <option>7:30am</option> <option>8:00am</option> <option>8:30am</option> <option>9:00am</option> <option>9:30am</option> <option>10:00am</option> <option>10:30am</option> <option>11:00am</option> <option>11:30am</option> <option>12:00pm</option> <option>12:30pm</option> <option>1:00pm</option> <option>1:30pm</option> <option>2:00pm</option> <option>2:30pm</option> <option>3:00pm</option> <option>3:30pm</option> <option>4:00pm</option> <option>4:30pm</option> <option>5:00pm</option> <option>5:30pm</option> <option>6:00pm</option> <option>6:30pm</option> <option>7:00pm</option> <option>7:30pm</option> <option>8:00pm</option> <option>8:30pm</option> <option>9:00pm</option> <option>9:30pm</option> <option>10:00pm</option> </select></p> </td> <td width=42 > <p><select multiple="multiple" size="3" style="width: 180%;"> <option>7:00am</option> <option>7:30am</option> <option>8:00am</option> <option>8:30am</option> <option>9:00am</option> <option>9:30am</option> <option>10:00am</option> <option>10:30am</option> <option>11:00am</option> <option>11:30am</option> <option>12:00pm</option> <option>12:30pm</option> <option>1:00pm</option> <option>1:30pm</option> <option>2:00pm</option> <option>2:30pm</option> <option>3:00pm</option> <option>3:30pm</option> <option>4:00pm</option> <option>4:30pm</option> <option>5:00pm</option> <option>5:30pm</option> <option>6:00pm</option> <option>6:30pm</option> <option>7:00pm</option> <option>7:30pm</option> <option>8:00pm</option> <option>8:30pm</option> <option>9:00pm</option> <option>9:30pm</option> <option>10:00pm</option> </select></p></td> <td width=42 > <p><select multiple="multiple" size="3" style="width: 180%;"> <option>7:00am</option> <option>7:30am</option> <option>8:00am</option> <option>8:30am</option> <option>9:00am</option> <option>9:30am</option> <option>10:00am</option> <option>10:30am</option> <option>11:00am</option> <option>11:30am</option> <option>12:00pm</option> <option>12:30pm</option> <option>1:00pm</option> <option>1:30pm</option> <option>2:00pm</option> <option>2:30pm</option> <option>3:00pm</option> <option>3:30pm</option> <option>4:00pm</option> <option>4:30pm</option> <option>5:00pm</option> <option>5:30pm</option> <option>6:00pm</option> <option>6:30pm</option> <option>7:00pm</option> <option>7:30pm</option> <option>8:00pm</option> <option>8:30pm</option> <option>9:00pm</option> <option>9:30pm</option> <option>10:00pm</option> </select></p></td> <td width=42> <p><select multiple="multiple" size="3" style="width: 180%;"> <option>7:00am</option> <option>7:30am</option> <option>8:00am</option> <option>8:30am</option> <option>9:00am</option> <option>9:30am</option> <option>10:00am</option> <option>10:30am</option> <option>11:00am</option> <option>11:30am</option> <option>12:00pm</option> <option>12:30pm</option> <option>1:00pm</option> <option>1:30pm</option> <option>2:00pm</option> <option>2:30pm</option> <option>3:00pm</option> <option>3:30pm</option> <option>4:00pm</option> <option>4:30pm</option> <option>5:00pm</option> <option>5:30pm</option> <option>6:00pm</option> <option>6:30pm</option> <option>7:00pm</option> <option>7:30pm</option> <option>8:00pm</option> <option>8:30pm</option> <option>9:00pm</option> <option>9:30pm</option> <option>10:00pm</option> </select></p></td> <td width=42 > <p><select multiple="multiple" size="3" style="width: 180%;"> <option>7:00am</option> <option>7:30am</option> <option>8:00am</option> <option>8:30am</option> <option>9:00am</option> <option>9:30am</option> <option>10:00am</option> <option>10:30am</option> <option>11:00am</option> <option>11:30am</option> <option>12:00pm</option> <option>12:30pm</option> <option>1:00pm</option> <option>1:30pm</option> <option>2:00pm</option> <option>2:30pm</option> <option>3:00pm</option> <option>3:30pm</option> <option>4:00pm</option> <option>4:30pm</option> <option>5:00pm</option> <option>5:30pm</option> <option>6:00pm</option> <option>6:30pm</option> <option>7:00pm</option> <option>7:30pm</option> <option>8:00pm</option> <option>8:30pm</option> <option>9:00pm</option> <option>9:30pm</option> <option>10:00pm</option> </select></p></td>; </tr> </table> </br> <input type="reset" value="Clear" /> <input type="submit" value="Submit" /> <input type="hidden" value="newuser" /> </form> </body> </html> I'm having on and off problems with a PaReq code that I receieve from PayPoint. This is part of a 3D Secure transaction. What happens is, I post to PayPoint the card information, They send me back a URL, MD Code and a PaReq code, The MD and URL are fine. BUT the PaReq is hit and miss. After consulting the tech support at PayPoint they are saying that occassionally the PaReq string is missing the "==" from the end of it. How can this be, If all I am doing is replicating what they send to me? My code is as follows... The Array I receieve from PayPoint : Code: [Select] array 'valid' => string 'true' (length=4) 'test_status' => string 'true' (length=4) 'trans_id' => string 'TRAN004' (length=7) 'mpi_status_code' => string '200' (length=3) 'mpi_message' => string 'Payer Verification Required' (length=27) 'acs_url' => string 'https%3A%2F%2Fwww.secpay.com%2Fjava-bin%2FACSSimulator%3Fpartner%3Dsecpay%26VAA%3DB' (length=83) 'MD' => string '1510881303' (length=10) 'PaReq' => string 'eJxVUlFvgjAQft+vIP4AWhANmqPGqcl8YHEb2zspF2SDggUG/vtdFdQ1aXLf3X29u+8Kq77IrV/UdVaqYOLYfLISTxAdNeL2A2WrUUCIdR2naGUJZcwc7vvOlE8nAg7rdzwJGOiC2LYLbITE0/IYq0ZALE/P+1fhuQvuesAGCAXq/VbM+HzqufTu9QC7ukHFBYpcYqly7gC7QJBlqxp9Fr47BzYCaHUujk1TLRnrus6+kjKFtizt9geYiQO793NojVXTe32WiDD67MNt6oVR2IXndbrf3G4AzGRAEjcoXO7Q4b7FF8uZt+Q0ycUPcWEaERSj7gcAlamxfow8eoCk1ajkOMmIAPuqVEgZpOTNhgRrKTZUTGcqtXanNqsKClADJgDsPtDmxcgtG1Lw63vnhtGuD9+CwIh+cZoCGWlGK3QuFQwAZmhs2CcbFk7Wv4/wB5zPtsU' (length=455) The HTML Form I send : Code: [Select] <form name='mainform' action='$threedurl' method='POST'> <center> <h1>Processing your 3D Secure Transaction</h1> <h3>Please click Submit to continue the processing of your 3D Secure transaction.</h3> <input type='submit' value='Submit'> </center> <input type='hidden' name='PaReq' value='$paymentauth'> <input type='hidden' name='TermUrl' value='http://localhost/Test Stuff/Payments/pares.php'> <input type='hidden' name='MD' value='$mdcode'> </form> <SCRIPT LANGUAGE='Javascript' > <!-- function OnLoadEvent() { document.mainform.submit(); } //--> PHP Code to load the array is : Code: [Select] <?php if(isset($_POST['submit'])) { extract ($_POST); $soapClient = new SoapClient("https://www.secpay.com/java-bin/services/SECCardService?wsdl"); $params = array( 'mid' => '', 'vpn_pswd' => '', 'trans_id' => 'TRAN000102', 'ip' => '127.0.0.1', 'name' => $card_name, 'card_number' => $card_number, 'amount' => $amount, 'expiry_date' => $card_expire_Month.$card_expire_Year, 'issue_number' => '', 'start_date' => '', 'order' => '', 'shipping' => '', 'billing' => '', 'options' => 'test_status=true, test_mpi_status=true', 'device_category' => '', 'accept_headers' => '', 'user_agent' => '', 'mpi_merchant_name' => '', 'mpi_merchant_url' => '', 'mpi_description' => '', 'purchaseRecurringFrequency' => '', 'purchaseRecurringExpiry' => '', 'purchaseInstallments' => '' ); $error = 0; try { // Call The Soap Client threeDSecureEnrolmentRequest - As Per Paypoint Docs... $result = $soapClient->__call("threeDSecureEnrolmentRequest", $params); } catch(SoapFault $fault) { $error = 1; if($fault->faultstring != 'Could not connect to host') { throw $fault; } } if ($error == 0) { $args = split("&", substr($result,1)); foreach ( $args as $arg) { list($key, $value) = explode("=", $arg); $result_arr[$key] = $value; } var_dump($result_arr); var_dump($params); print_r($_POST); $mpistatus = $result_arr['mpi_status_code']; if ($mpistatus == '200') { $threedurl = urldecode($result_arr['acs_url']); $paymentauth = $result_arr['PaReq']; $mdcode = $result_arr['MD']; echo "<form name='mainform' action='$threedurl' method='POST'> <center> <h1>Processing your 3D Secure Transaction</h1> <h3>Please click Submit to continue the processing of your 3D Secure transaction.</h3> <input type='submit' value='Submit'> </center> <input type='hidden' name='PaReq' value='$paymentauth'> <input type='hidden' name='TermUrl' value='http://localhost/Test Stuff/Payments/pares.php'> <input type='hidden' name='MD' value='$mdcode'> </form> <SCRIPT LANGUAGE='Javascript' > <!-- function OnLoadEvent() { document.mainform.submit(); } //--> </SCRIPT> "; } else { echo "Fine"; } } } ?> Any hints, tips or answers on this are much appreciated, As this is an ongoing issue that I'd love to solve. It appears the tech support I've receieved has been pretty poor. Greetings, I am trying to create a basic booking system, for example there may be 3 events that a user can book. If the user clicks 'Book Now' on Event #1 I need it to take them to the HTML/PHP booking form with the information already entered that is relevant to Event #1 (Or whatever event they choose), such as the event name, time, date etc I know how to create a contact form etc, its just the carrying of the information over to the form I dont know how to do. Does anyone know if this is possible/ how it could be achieved? Any help will be much appreciated, Thanks! Good afternoon,
I was wondering if you could help me out with a few things. I have created a registration page and it stores the information into my database. A success page then appears with some of the details they entered as a confirmation page. Unfortunately I cannot get the information to appear on the page. I have included some code, any help would be greatly appreciated.
<?php Hey guys, I'm going to start working on a simple php/mysql project, and wondering if you guys could point me in the right direction. Here is what I want to do: 1. User is presented with a simple form asking a series of questions (including email address) 2. Based on the answers, a specific download link is emailed to the user 3. store all inputted information in the database. I'm still not sure if I want the email process to be automated, or "held" until the information is reviewed, then download link sent. Does anyone know if a script already exist for this? I don't need to create user accounts, I just want to obtain user information every time they want to download something. Thanks for any help. I am trying to set up a script that will capture a form's data, create a .csv and email it. The code I have returns no errors but will not send the email. Any help please. <?php $cr = "\n"; $csvdata = "First Name" . ',' . "Last Name" . ',' . "Email" . ',' . "Telephone" . ',' ."Comments" . $cr; $csvdata .= $first_name . ',' . $Last_Name . ','. $email . ',' . $telephone .',' . $comments . $cr; $thisfile = 'member.csv'; $encoded = chunk_split(base64_encode($csvdata)); // create the email and send it off $subject = "new member"; $from = "michael@davisgutierrez.com"; $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-Type: multipart/mixed; boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . "\n"; $message = ' This is a multi-part message in MIME format. ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello We have attached for you the PHP script that you requested from http://rrwh.com/scripts.php as a zip file. Regards ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: application/octet-stream; name="'; $message .= "$thisfile"; $message .= '" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="'; $message .= "$thisfile"; $message .= '" '; $message .= "$encoded"; $message .= ' ------=_NextPart_001_0011_1234ABCD.4321FDAC-- '; // now send the email mail($email, $subject, $message, $headers, "-f$from"); echo $mail_sent ? "Mail sent" : "Mail failed"; ?> I am trying to have a form that is filled out through the a website email me with the info the entered...the code is below, the problem is when you hit send it goes the the next page which says email was sent but no email is sent... CODE.... Code: [Select] <?php $firstname = $_POST['firstname']; $question = $_POST['question']; $username = $_SESSION['username']; if ($_POST['submit']) { //connect to database $connect = mysql_connect("db","user","pass") or die("Not connected"); mysql_select_db("user") or die("could not log in"); //grab email from database $query = "SELECT * FROM table WHERE username='$username'"; $result = mysql_query($query); $row = mysql_fetch_array($result); //set email to variable name $email = $row['email']; //set SMTP $server = "smtp.gmail.com"; ini_set("SMTP",$server); //setup variables $to = "Collegebooxstore@gmail.com"; $subject = "Member Contact Us"; $body = "This is an email from $firstname\n\n email $email\n\n\n $question"; $headers = "From: $email"; //existance check if ($firstname&&$question) { mail($to, $subject, $body, $headers); } else die('Please make sure your filled in your firstname as well as a Quesiton/Comment!'); } ?> I have little or no! idea what I am doing.. But I foolishly decided I would try some coding.. What I want is to query two table and then send an email to each record holder in the database. I have pieced together this... But it doesn't give me the results of all my vaiables and it doesn't email all the results. Ideas, directions anything would be helpful.. <?php include "vsadmin/db_conn_open.php"; $allprods=mysql_query("select pID, pName, pPrice, pDropship, dsID, dsName, dsEmail from products, dropshipper where pDropship = dsID"); while ($yarr=mysql_fetch_assoc($allprods)) $aname=$yarr["pID"]; $bname=$yarr["pName"]; $cname=$yarr["dsName"]; $to = "author@email.com"; $subject = ("Your Ebook " . $aname); $body = ("Hello,\n\nHow are you you ". $aname ."?\n\nWhats New With you in the World?" . $aname ) ; $headers = "From: me@me.com\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent again!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> |