PHP - Trying To Display Information From Form After It Is Submitted (confirmation Page)
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
Similar Tutorialshow can i disply this message withing the form echo "data submitted successfully!"; currently after validation check when data is entered the message show on top of my page not within the form function insertDATA($postData) { if(!ifEmailExists($postData['email'])){ $sql = " INSERT INTO tbl SET email = '".$postData['email']."', name = '".$postData['name']."', phone = '".$postData['phone']."' "; echo "data submitted successfully!";//this line withing the form executeSql($sql); } I am fairly new to PHP and am having an issue with getting my form to redirect to a thank you page upon sending the form email. I currently have it set to echo a thank you message but it needs to be changed to ensure that we can track all form fills better. I have tried the header method but it doesn't work correctly based on how the website is designed. It seems like there should be an easy way without redesigning too much. Are there any other ways to accomplish this? Please let me know what I need to do in order to get the redirect to work. Hi, So I am currently making a real estate site for my class at school but I am having a tiny issue with the listing display page. So what I want to do is show a bunch of listing that the agent owns on their dashboard which I have already done. Now I have two links one to update the listing and one to view the listing. Now what I am trying to do is when the view listing link is clicked it will take the user to the listing-display page and then I want it to display all the information for the listing that the link was clicked under. But i cannot for the life of me figure out how to do that!
This is currently the code for the dashboard where you only view the listing headline <?php // If the session was never set with a user id $output = ''; $conn = db_connect(); if($_SESSION['userType'] != AGENT) { $_SESSION['RedirectError'] = "You were not logged in as an Agent<br/>"; header("Location:login.php"); } if (isset($_GET["page"])) { $page = $_GET["page"]; $index = ($page -1) * IMAGE_LIMIT; } else { $page=1; $index = 0; } ?> <!-- start of main page content --> <div class="container" style="margin-top: 2em;"> <h2>Dashboard</h2> <p>Welcome back <?php echo $_SESSION['userId']; ?> you last logged in on <?php echo $_SESSION['last_access']; ?></p> <h4>Your Listings</h4> <?php $sql = "SELECT listing_id FROM listings WHERE user_id = '".$_SESSION['userId']."' AND status = 'o' ORDER BY listing_id"; $result = pg_query($conn, $sql); $listings = pg_fetch_all($result); for($index; $index < pg_num_rows($result); $index++) { $sql = "SELECT * FROM listings WHERE listing_id = '".$listings[$index]['listing_id']."'"; $listing_result = pg_query($conn, $sql); $arrayRow = pg_fetch_assoc($listing_result); echo (build_listing_card($arrayRow)); if($index !=0 && ($index +1) % IMAGE_LIMIT ==0){ break; } } ?> </div> <br/> <?php $total_pages = ceil(count($listings) / IMAGE_LIMIT); $pageLink = "<div class='pagination'>"; for ($i=1; $i<=$total_pages; $i++) { if($i == $page) { $pageLink .= "<a class='active' href='dashboard.php?page=".$i."'>".$i."</a>"; } else { $pageLink .= "<a href='dashboard.php?page=".$i."'>".$i."</a>"; } }; ?> </div> <br/>
and this is the code for the listing-display page where I want all the listing information to be displayed <?php if (isset($_GET['listing_id'])) { $_SESSION['listing_id'] = $_GET['listing_id']; } else { $_SESSION['listing_id'] = 0; echo "ERROR: listing information was not find"; } $sql = 'SELECT * FROM listings WHERE listing_id = ' . $_SESSION['listing_id']; echo "<BR>".$sql; $result = pg_query(db_connect(), $sql); $records = pg_num_rows($result); echo "<BR>".pg_fetch_result($result, 0, "listing_id"); echo "<BR>".pg_fetch_result($result, 0, "user_id"); echo "<BR>".pg_fetch_result($result, 0, "status"); echo "<BR>".pg_fetch_result($result, 0, "price"); echo "<BR>".pg_fetch_result($result, 0, "headline"); echo "<BR>".pg_fetch_result($result, 0, "description"); echo "<BR>".pg_fetch_result($result, 0, "postal_code"); echo "<BR>".pg_fetch_result($result, 0, "images"); echo "<BR>".pg_fetch_result($result, 0, "city"); echo "<BR>".pg_fetch_result($result, 0, "property_options"); echo "<BR>".pg_fetch_result($result, 0, "bedrooms"); echo "<BR>".pg_fetch_result($result, 0, "bathrooms"); echo "<BR>".pg_fetch_result($result, 0, "garage"); echo "<BR>".pg_fetch_result($result, 0, "purchase_type"); echo "<BR>".pg_fetch_result($result, 0, "property_type"); echo "<BR>".pg_fetch_result($result, 0, "finished_basement"); echo "<BR>".pg_fetch_result($result, 0, "open_house"); echo "<BR>".pg_fetch_result($result, 0, "schools"); ?> <h1> Listing Display </h1> <hr/> <table style="width:50%" border="1px solid black"> <tr> <th>Listing Image</th> <th>Listing Description</th> </tr> <tr> <th rowspan="2"> <img src="" alt="Oshawa House" width="300px" height="200px"/> </th> <td align="left" valign="top"> <h3><?php echo pg_fetch_result($result, 0, "headline") ?></h3> <ul> <li>Open house?: <?php echo get_property('open_house', pg_fetch_result($result, 0, "open_house"))?> </li> <li>Finished Basement?: <?php echo get_property('finished_basement', pg_fetch_result($result, 0, "finished_basement"))?></li> <li><?php echo get_property('purchase_type', pg_fetch_result($result, 0, "purchase_type"))?></li> <li>Garage Type: <?php echo get_property('garage_type', pg_fetch_result($result, 0, "garage"))?></li> <li>Near school?: <?php echo get_property('schools', pg_fetch_result($result, 0, "schools"))?></li> <li>Status: <?php echo get_property('listing_status', strtolower(pg_fetch_result($result, 0, "status"))) ?></li> <li>Washrooms: <?php echo get_property('washrooms',pg_fetch_result($result, 0, "bathrooms")) ?></li> <li>Bedrooms: <?php echo get_property('bedrooms',pg_fetch_result($result, 0, "bedrooms")) ?></li> <li>Description: <?php echo pg_fetch_result($result, 0, "description") ?></li> </ul> </td> </tr> <tr> <td align="left" valign="top"><ul> <li>Location: <?php echo get_property('cities',pg_fetch_result($result, 0, "city")) ?></li> <li>Postal Code: <?php echo pg_fetch_result($result, 0, "postal_code") ?></li> <li>Price: <?php echo pg_fetch_result($result, 0, "price") ?></li> </ul> </td> </tr> </table> <form action="listing-matches.php"> <p> <input type="submit" name="submit" value="Back"/></p> </form>
Hello! I have a 2 questions: Q1: How do you store answers from a php file(see code below) into another file?(php preferably) I know it would probably be easier using a database, but I would like to know how to do it with a text/php file. Below you can see a piece of code for a page students would go on to fill in online exercices. They would first have to input their names. These names would have to be sent to a php file called "StudentAnswers.php". As well as their answers I also have another file that is called "QandA.php" which is called on with include in the piece of code below so the students can't see the answers before they submitted their answers. Q2: But how do I complete the if code(see question marks) so the answer only shows IF(as soon as) they clicked on the submit button? Code: [Select] <html> <body> <h2>Exercices</h2> <p> <form name="input" action="StudentAnswers.php" method="get"> Student name: <input type="text" name="user" /> </form> </p> <p> What is the gradient of T(x,y)=2x+3? <form name="input" action="StudentAnswers.php" method="get"> <input type="text" name="1b" /> <input type="submit" value="Input answer"/> </form> if ( ????????? ) { ???????"; } <?php include("QandA.php"); echo $Question["1b"];?> <p> </body> </html> B 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"); } } ?> Hello all, Im making a Quote Request Form for my dads company. So first they have the actual form then they click submit and it going to a confirmation page so they can review their information, at the confirmation page i want the end user to be able to click confirm and it sends the form to my e-mail. and if they made a mistake to be able to click button saying go back and they just change the information. I tried to set it up that way but when i click submit, it says it submitted and i got the e-mail but none of the info was there, and the back button kept me on the confirmation page but erased all the data. Up until now, I have been writing Forms that submit back to themselves. Now I want to break up my code. I usually have this PHP at the top of my forms... Code: [Select] <?php // ******************************************** // HANDLE FORM. * // ******************************************** if ($_SERVER['REQUEST_METHOD']=='POST'){ // Form was Submitted (Post). If I change my Form Action to point to another script, will this code work in that new script?? (In other words, will Script_B be able to detect $_SERVER['REQUEST_METHOD']=='POST' ??) Thanks, Debbie I now know how to append GET over normal hyperlinks, but I don't know how to do it with form submissions. Here's the problem: I have a form like this one: <form method="GET" action=""> <?php require_once ('sort_category_func.php'); $switch = 1; sort_category ($switch); ?> + Most Liked <input type='checkbox' value='mostLiked' name='mostLiked' /> <br /> <input type="submit" name="sortSubmit" value='Go' /> <br /><br /> </form> And the variables: // DROP DOWN MENU VARIABLES $select_category = $_REQUEST['sort_category']; $most_liked = $_GET['mostLiked']; I'm using a while loop to list user submission, you can also sort them by category which works over GET, this works as long as there is no GET data already in the URL, but as soon as there is GET data it won't work anymore. Here's an example: If I have a user profile page opened like this: profile.php?user=konopkov And a category has been chosen to sort the user's submissions the URL will change to: profile.php?sort_category=Logos INSTEAD it should be: profile.php?user=konopkov&sort_category=Logos As I said I know how to achieve this with hyperlinks now, but I have no clue how do it with form submissions. Any suggestions? Thanks. I've got a BIG problem... When a user submits my form it works fine, displays a "Transaction Success/Failed", and e-mails me a confirmation. However, if the user then navigates to another page (e.g. "Home"), and then clicks their browser's "Back" button, my form gets re-submitted?! This is on a VPS, but I just chatted with server support and they are saying, Quote register_globals = Off So what is going wrong?! Debbie I'm trying to incorporate a confirmation email function into an existing php script. I have a form that works perfectly, but I can't figure out how to get it to send an email confirmation. Here's the code ... sorry for posting so much of it, but in case I miss anything ... here it is. It's hosted on GoDaddy on a Linux platform ... if that makes any difference. If anyone can enlighten me ... Please Do. Thanks! <?php $d = date("m-d-y H:i:s"); // assign incomming data $CustomerStatus = $_POST["CustomerStatus"]; $Contact = $_POST["Contact"]; $Name = $_POST["Name"]; $an = str_replace(" ", "", $Name); $Company = $_POST["Company"]; $Address = $_POST["Address"]; //$office = $_POST["office"]; $CityStateZip = $_POST["CityStateZip"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $ResponseType = $_POST["ResponseType"]; $Artwork = $_POST["Artwork"]; $ProjectName = $_POST["ProjectName"]; $DueDate = $_POST["DueDate"]; $EstimateNumber = $_POST["EstimateNumber"]; $PONumber = $_POST["PONumber"]; $Pages = $_POST["Pages"]; $Quantity = $_POST["Quantity"]; $ColorFrontBack = $_POST["ColorFrontBack"]; $FlatSize = $_POST["FlatSize"]; $FoldedSize = $_POST["FoldedSize"]; $StockText = $_POST["StockText"]; $StockCover = $_POST["StockCover"]; $LabelStock = $_POST["LabelStock"]; $Coating = $_POST["Coating"]; $Bindery = $_POST["Bindery"]; $Additional = $_POST["Additional"]; $group1 = $_POST["group1"]; $group2 = $_POST["group2"]; $group3 = $_POST["group3"]; $redirect = $_POST["redirect"]; //$subject = $_POST["Subject"]; /* ************* Begin Configuration ************* */ $relocate = "http://www.xxxxx.com/"; // insert your relocation url here $home = "http://www.xxxxx.com/"; $MOVE_TO_PATH = '/home/content/xxxxx/html/FileUpload/'; $PATH_TO_DIR = 'http://www.xxxxx.com/FileUpload/'; // The following values are used to verify_uploaded_file() as the sizes and types that can be uploaded. $UPLOAD_TYPES['PSD'] = 1; // Allow .psd files $UPLOAD_TYPES['JPG'] = 1; // Allow .jpg files (definition must be upper case) $UPLOAD_TYPES['JPEG'] = 1; // Allow .jpeg files $UPLOAD_TYPES['AI'] = 1; // Allow .ai files $UPLOAD_TYPES['EPS'] = 1; // Allow .eps files $UPLOAD_TYPES['PDF'] = 1; // Allow .pdf files $UPLOAD_TYPES['GIF'] = 1; // Allow .gif files $UPLOAD_TYPES['PNG'] = 1; // Allow .png files $UPLOAD_TYPES['DOC'] = 1; // Allow .doc files $UPLOAD_TYPES['XLS'] = 1; // Allow .xls files $UPLOAD_TYPES['ZIP'] = 1; // Allow .zip files $UPLOAD_TYPES['SIT'] = 1; // Allow .sit files $UPLOAD_TYPES['FLA'] = 1; // Allow .fla files $UPLOAD_SIZES['max'] = 180000000; // Maximum size -- Make sure the file is under 180 MB : 180,000,000 = 180 MB $UPLOAD_SIZES['min'] = 0; // Minimum size -- Arbitrary small file size to distinguish between no file and file submission $sender_name = "Order"; $sender_email = "me@xxxxx.com"; $mailheaders = "Content-Type: text/plain; charset=us-ascii\nFrom: $sender_name <$sender_email>\nReply-To: <$sender_email>\nReturn-Path: <$sender_email>\nX-Mailer: PHP"; //$to = "me@xxxxx.com"; $to = "me@xxxxx.com"; $subject = "Order"; $msg ="$d\n\n"; $msg .= "CustomerStatus: $CustomerStatus\n"; $msg .= "Contact: $Contact\n"; $msg .= "Name: $Name\n"; $msg .= "Company: $Company\n"; $msg .= "Address: $Address\n"; $msg .= "CityStateZip: $CityStateZip\n"; $msg .= "Phone: $Phone\n"; $msg .= "Email: $Email\n"; $msg .= "ResponseType: $ResponseType\n"; $msg .= "Artwork: $Artwork\n"; $msg .= "ProjectName: $ProjectName\n"; $msg .= "DueDate: $DueDate\n"; $msg .= "EstimateNumber: $EstimateNumber\n"; $msg .= "PONumber: $PONumber\n"; $msg .= "Pages: $Pages\n"; $msg .= "Quantity: $Quantity\n"; $msg .= "ColorFrontBack: $ColorFrontBack\n"; $msg .= "FlatSize: $FlatSize\n"; $msg .= "FoldedSize: $FoldedSize\n"; $msg .= "StockText: $StockText\n"; $msg .= "StockCover: $StockCover\n"; $msg .= "LabelStock: $LabelStock\n"; $msg .= "Coating: $Coating\n"; $msg .= "Bindery: $Bindery\n"; $msg .= "Additional: $Additional\n"; $msg .= "group1: $group1\n"; $msg .= "group2: $group2\n"; $msg .= "group3: $group3\n"; $success_block = "<p>Thank you for submitting your information. We will review your information and get back to you within a day or two.</p><br><br>"; /* ************* End Configuration ************* */ Hello everyone, I'm having a difficult time figuring out what my problem is here. I'm trying to submit a couple of strings (to the user they are messages to be sent to other users) and I am having trouble with the string being cut off at quotation marks. Here is the code that I'm using: Code: [Select] <?php if (isset($_POST['submit'])) { $staffmessage = $_POST['staffmessage']; $studentmessage = $_POST['studentmessage']; echo "$staffmessage<br /> <br />$studentmessage"; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $message1="This is a test message. It does not get cut off here when the \"quotation marks\" are added."; $message2="This is a test message. It DOES get cut off here when the \"quotation marks\" are added."; ?> <form name="form" method="post" action="test.php"> <textarea class="textarea" name="staffmessage" rows="12"> <?php echo $message1; ?> </textarea></p> <input name="studentmessage" type="hidden" value="<?php echo $message2; ?>" /> <input class="submit2" type="submit" name="submit" value="Send Message" /> </form> </body> </html> The result that I'm getting is that when $staffmessage is echoed, I get the full message. When $studentmessage is echoed, the message gets cut off at the first quotation mark. The only thing that is different when creating these two variables is that $staffmessage is submitted using a "textarea" field in the form, and $studentmessage is submitted using a "hidden" field in the form. Other than that, they are handled the exact same way. Can anyone please help me figure out how to remedy this so that $studentmessage is not cut off at the quotation mark? Thanks in advance for your help! Hi: I am using this code for my contact us feedback form: Code: [Select] <?php $error = NULL; $myDate = NULL; $FullName = NULL; $Address = NULL; $City = NULL; $State = NULL; $Zip = NULL; $Phone = NULL; $Email = NULL; $Website = NULL; $Comments = NULL; if(isset($_POST['submit'])) { $myDate = $_POST['myDate']; $FullName = $_POST['FullName']; $Address = $_POST['Address']; $City = $_POST['City']; $State = $_POST['State']; $Zip = $_POST['Zip']; $Phone = $_POST['Phone']; $Email = $_POST['Email']; $Website = $_POST['Website']; $Comments = $_POST['Comments']; if(empty($FullName)) { $error .= '-- Enter your Full Name. <br />'; } if(empty($Email)) { $error .= '-- Enter your Email. <br />'; } if($error == NULL) { $sql = sprintf("INSERT INTO myContactData(myDate,FullName,Address,City,State,Zip,Phone,Email,Website,Comments) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($myDate), mysql_real_escape_string($FullName), mysql_real_escape_string($Address), mysql_real_escape_string($City), mysql_real_escape_string($State), mysql_real_escape_string($Zip), mysql_real_escape_string($Phone), mysql_real_escape_string($Email), mysql_real_escape_string($Website), mysql_real_escape_string($Comments)); if(mysql_query($sql)) { $error .= 'Thank you for contacting us.'; mail( "d@direct.com", "Contact Request", "Date Sent: $myDate\n Full Name: $FullName\n Address: $Address\n City: $City\n State: $State\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Website: $Website\n Comments: $Comments\n", "From: $Email" ); } else { $error .= 'There was an error in our Database, please Try again!'; } } } echo '<span class="textError">' . $error . '</span>'; ?> <form name="myform" action="" method="post"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> <div id="tableFormDiv"> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">* - Required</span></span> <span class="floatFormLeft"> </span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Full Name:</span> <span class="floatFormLeft"><input type="text" name="FullName" size="45" maxlength="50" value="<?php echo $FullName; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Address:</span> <span class="floatFormLeft"><input type="text" name="Address" size="45" maxlength="50" value="<?php echo $Address; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">City:</span> <span class="floatFormLeft"><input type="text" name="City" size="45" maxlength="50" value="<?php echo $City; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">State:</span> <span class="floatFormLeft"><input type="text" name="State" size="45" maxlength="50" value="<?php echo $State; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Zip:</span> <span class="floatFormLeft"><input type="text" name="Zip" size="45" maxlength="50" value="<?php echo $Zip; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Phone:</span> <span class="floatFormLeft"><input type="text" name="Phone" size="45" maxlength="50" value="<?php echo $Phone; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Email:</span> <span class="floatFormLeft"><input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Website:</span> <span class="floatFormLeft"><input type="text" name="Website" size="45" maxlength="50" value="<?php echo $Website; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Comments:</span> <span class="floatFormLeft"><textarea name="Comments" cols="40" rows="10"><?php echo $Comments; ?></textarea></span></fieldset> </div> <input type="submit" name="submit" value="Submit" class="submitButton" /><br /> </form> I the only thing I can't figure out is, how do I clear the form fields AFTER the form has been submitted and the message "Thank you for contacting us." appears ?? I haven't been able to figure it out with JavaScript/PHP, so I posted my original code in hopes that someone will have an idea. Anyone? Thanks! I have an account on theirsite.com and I want to be able to submit my login credentials from mysite.com/page1.php and then redirect back to mysite.com/page2.php. I've been Googling for hours now and nothing I can find works and I don't know a thing about cURL and would rather not get into it. Not to mention, I'm using free hosting for now and I don't believe I'm able to use cURL anyways. I can get it to log in with the credentials just fine, that's no problem, but I just have no clue how to get it to redirect back to my page or just send the credentials and then staying on my page because I could work with that as well (send credentials to theirsite.com from mysite.com/page1.php and staying on mysite.com/page1.php). Is there anyone that could give me a hand on how to do this without using cURL since my php.ini is not editable? Thanks Hi
We have a nicely working smtp contact form, however the form redirects to the contact.php file as default I presume, when we want it to go to a thank you page. Can you [please take a look at the code below and clarify where I need to put the thank you page URL;
$redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form $mail->From = $mail->Username; //Default From email same as smtp user $mail->FromName = "Mobile website"; $mail->AddAddress("essexcarrentals@yahoo.co.uk", "Mobile Website"); //Email address where you wish to receive/collect those emails. $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $_POST['Enquiry']; $message = "Name: ".$_POST['name']." \r\n <br>Email Address: ".$_POST['email']." \r\n <br> Phone: ".$_POST['phone']." \r\n <br> Vehicle: ".$_POST['select']." \r\n <br> Dates: ".$_POST['dates']; $mail->Body = $message; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; header("Location: $redirect_url"); } ?> I have tried replacing the http:// but this returns a page underfined error on submission? We appreciate your help on this one guys :0) Ash --- Hello. I currently have a web page that allows a user to enter text into a form then select a "Submit Query" button; upon doing this the entered text is saved to a database and displayed for the user on the same page (the page where the form and "Submit Query" button are located). My question is as follows: I wish the results to be displayed on a new page when the "Submit Query" button is clicked, not displayed on the same page. Is this achieved through targeting? I am a bit lost at this point on how to achieve this result. Thank-you in advance for any help. ~Matty Hi.. all I have a problem in my web site. There I have created a page call download.php and using it users can download song. I used a form to download button to display download box. after users click on download link i need to cancel it on that page. that mean I want to disappear it on download.php page. now when i click on browser's refresh button that download box still display on page. so any body can i help me to do it.. http://www.mist.lk/d...ad.php?index=52 thanks in advance for any help.... Hello all, I am having a bit of trouble with this contact form. Everything submits fine, errors work and all but the information isn't sent to my inbox. Can anyone point out where the problem is? Thanks in advance! Code: [Select] if(isset($_POST['Email_Address'])) { include 'free_settings.php'; function died($error) { echo "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(); } if(!isset($_POST['Full_Name']) || !isset($_POST['Email_Address']) || !isset($_POST['Your_Message'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $full_name = $_POST['Full_Name']; // required $email_from = $_POST['Email_Address']; // required $comments = $_POST['Your_Message']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(preg_match($email_exp,$email_from)==0) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($full_name) < 2) { $error_message .= 'Your Name does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\r\n"; $email_message .= "Email: ".clean_string($email_from)."\r\n"; $email_message .= "Message: ".clean_string($comments)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <?php Hi, Say I have the situation shown below: Here is my code below. What I’m having a problem with is trouble to find how to sticky my checkbox and get to the confirmation page after clicking the submit input. I also need on the confirmation page to list what fields are not filled in.
<head> <meta http-equiv="Content-Type"content="text/html; charset=utf-8' /> <title>Assignment 4</title> <style type="text/css" title="text/css" media="all"> </style> </head> <div align="center"> <img src="nba2k20cover.jpg" alt="nba2k20 cover" width="616" height="353" /> <br> <br> <?php include('header.php'); ?> <h4> Hosted by: Zang Thao</h4> <h5> You are required to complete every field to your best!</h5> <body> <?php $name = $_POST['name']; $comments = $_POST['comments']; $gender = $_POST['gender']; $email = $_POST['email']; $league = $_POST['league']; $submit = $_POST['submit']; $monthsarray = array("Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $days = range(1,31); $daysdefault = array ('Day'); $daysarray = array_merge($daysdefault, $days); $years = range(2002,1910); $yearsdefault = array ('Year'); $yearsarray = array_merge($yearsdefault, $years); ?> <form name ="fbForm" id="fbForm" action="<?php if(($errors = NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')) { echo "handle.php"; $submit = true; } else { echo "index.php"; } ?>" method="post"> <fieldset><legend>Fill out the registration form below:</legend> <?php if(($_POST['name'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')) { echo "<b>Please enter a name!</b>"; } ?> <p><label>Name: <input type="text" name="name" size="20" maxlength="40" value="<?php echo $_POST['name']; ?>" /></label></p> <?php if($_POST['email'] == NULL) { echo "<b>Please enter your email!</b>"; } ?> <p><label>Email Address: <input type="text" name="email" size="40" maxlength="60" value="<?php echo $_POST['email']; ?>" /></label></p> <?php if($_POST['gender'] == NULL) { echo "<b>Please select your gender!</b>"; } ?> <p><label for="gender">Gender:</label><input type="radio" name="gender" value="M"<?php if($_POST['gender'] == "M") { echo "checked"; } ?> /> Male<input type="radio" name="gender" value="F" /> Female</label></p> <?php if($_POST['month'] == NULL) { echo "<b>Please enter a birthday!</b>"; } ?> <p><label>Birth Date: <select name="month"> <?php foreach ($monthsarray as $value) { if($_POST['month'] == $value) { $isselected = "selected"; } else { $isselected = ""; } echo "<option value='$value' $isselected>$value</option> \n"; } ?> </select> <select name="day"> <?php foreach ($daysarray as $value) { if($_POST['day'] == $value) { $isselected = "selected"; } else { $isselected = ""; } echo "<option value='$value' $isselected>$value</option> \n"; } ?> </select> <select name="year"> <?php foreach ($yearsarray as $value) { if($_POST['year'] == $value) { $isselected = "selected"; } else { $isselected = ""; } echo "<option value='$value' $isselected>$value</option> \n"; } ?> </select></label></p> <?php if($_POST['league'] == NULL) { echo "<b>Please select a league!</b>"; } ?> <p><label for="league">Choose your league:</label><input type="checkbox" name="league" value="A"<?php if($_POST['opt'] == "A") { echo "checked"; } ?> /> A <input type="checkbox" name="league" value="B" <?php if($_POST['opt'] == "B") { echo "checked"; } ?>/> B <input type="checkbox" name="league" value="C" <?php if($_POST['opt'] == "C") { echo "checked"; } ?>/> C <input type="checkbox" name="league" value="D" <?php if($_POST['opt'] == "D") { echo "checked"; } ?>/> D</p> <?php if($_POST['comments'] == NULL) { echo "<b>Write down your questions/concerns if you don't have any write N/A!</b>"; } ?> <p><label>Questions/Concerns: <textarea name="comments" rows="3" cols="40"><?php echo $_POST['comments']; ?></textarea></label></p> </fieldset> <?php if ($submit) { echo"<script>document.getElementById('fbForm').submit();</script> "; } ?> <p align="center"><input type="submit" name="submit" value="REGISTER!" /></p> </form> <?php include('footer.php'); ?> </body> </html>
Following is the form.Now i want to see if submit button is pressed or not.Usually if html had Code: [Select] <input type="submit" value="Submit" name = "submit" /> i would simply use Code: [Select] <?php if(isset($_POST['submit'])) ?> But below is the form which has an image as a submit button Form - Code: [Select] <form action="" method="post" id="sendemail"> <ol> <li> <label for="name">Name (required)</label> <input id="name" name="name" class="text" /> </li> <li> <label for="email">Email Address (required)</label> <input id="email" name="email" class="text" /> </li> <li> <label for="email">Phone number</label> <input id="phone" name="phone" class="text" /> </li> <li> <label for="address">Address(required)</label> <input id="address" name="address" class="text" /> </li> <li> <label for="city">City(required)</label> <input id="city" name="city" class="text" /> </li> <li> <label for="state">State(required)</label> <input id="state" name="state" class="text"/> </li> <li> <label for="zipcode">Pincode/Zipcode(required)</label> <input id="zipcode" name="zipcode" class="text" /> </li> <li> <input type="image" name="submit" id="imageField" src="images/submit.gif" class="send" /> <div class="clr"></div> </li> </ol> </form> How should i check if form is submitted or not when instead of submit button there is an image ? ----------------------------------------------------------------- Alternative Solution ---------------------------------------------------------------------------- I tried sending it to other page but then i had to send an array back to this page and i didn't know how to send that either.I tried Code: [Select] <?php $error = serialize($error); echo "<meta http-equiv='refresh' content='0;url=about.php?array=".$error."'> "; ?> But even after Code: [Select] $array = unserialize($array); $array contained nothing. Can someone please show me how to send in array in between pages for future ? |