PHP - Actions In A Form
I have a problem regarding with actions. I have a dynamic dropdown list (attached), that when the selected value is student, a form will show..I am using a submit button, the problem is how am I going to save the form for student.
[attachment deleted by admin] Similar TutorialsHi, I have a page with a PayPal button at the bottom. I am attempting to run two actions when the PayPal button is pressed. One is to process the PayPal payment and the other that opens another page which I have called testpage.php
I have used a script I found online as I have no experience in Javascript, this is meant to run two actions when the PayPal button is clicked. However only the testpage.php opens.
Here is what i got, have I done it wrong? Or is there a better way to do this?
<?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; ?> <script language="Javascript"> <!-- function OnButton1() { document._xclick.action = "https://www.paypal.com/cgi-bin/webscr" // document._xclick.target = "_blank"; // Open in a new window document._xclick.submit(); // Submit the page return true; } function OnButton2() { document._xclick.action = "testpage.php" document._xclick.target = "_blank"; // Open in a new window // document._xclick.submit(); // Submit the page return true; } --> </script> <?php if (!isset($_SESSION['loggedin'])) { die("You must be logged in to view this page!"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $business = $row['paypal_email']; $user_id = $_GET['user_id']; $results1 = $con->query("SELECT * FROM live_sales WHERE user_id = '$user_id';"); while($row = $results1->fetch_array()) { $username = $row['username']; $fishtype = $row['fishtype']; $speciesCommon = $row['speciesCommon']; $speciesScientific = $row['speciesScientific']; $listing_title = $row['listing_title']; $age = $row['age']; $quantity = $row['quantity']; $origin = $row['origin']; $size = $row['size']; $environment = $row['environment']; $waterChemistry = $row['waterChemistry']; $temperature = $row['temperature']; $feeding = $row['feeding']; $sexing = $row['sexing']; $compatability = $row['compatability']; $temperament = $row['temperament']; $breeding = $row['breeding']; $comments = $row['comments']; $postage_type = $row['postage_type']; $postage_cost = $row['postage_cost']; $multipostage = $row['multipostage']; $cost = $row['cost']; echo "<div class='result'>"; echo "<h3>$speciesCommon</h3>"; echo "<h2>$listing_title</h2>"; echo "<ul class='results'>"; echo "<li>Species</li>" . str_replace("_"," "," $fishtype") . "<br>"; echo "<li>Common Name:</li> $speciesCommon<br>"; echo "<li>Scientific Name:</li> $speciesScientific<br>"; echo "<li>Age:</li> $age<br>"; echo "<li>Quantity:</li> $quantity<br>"; echo "<li>Price per item:</li> £$cost<br>"; echo "<li>Origin:</li> $origin<br>"; echo "<li>Size:</li>$size<br>"; echo "<li>Environment:</li> $environment<br>"; echo "<li>Water Chemistry</li> $waterChemistry<br>"; echo "<li>Temperatu </li> $temperature<br>"; echo "<li>Feeding:</li> $feeding<br>"; echo "<li>Sexing:</li> $sexing<br>"; echo "<li>Compatability:</li> $compatability<br>"; echo "<li>Temperament:</li> $temperament<br>"; echo "<li>Breeding:</li>$breeding<br>"; echo "<li>Comments:</li> $comments<br>"; echo "<li>Postage Type:</li>$postage_type<br>"; echo "<li>Postage Cost:</li> £$postage_cost $multipostage<br>"; ?> </ul> </div> <div align='center'> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <?php echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; if( $multipostage == "per item" ) { $postage_cost = $quantity * $postage_cost; } elseif( $multipostage == "Combined Postage" ) { $postage_cost; } ?> <br><br> <input type="hidden" name="shipping" value="<?php echo $postage_cost ?>"> <input type="hidden" name="business" value="<?php echo $business ?>"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="item_name" value="<?php echo $speciesCommon ?>"> <input type="hidden" name="amount" value="<?php echo $cost ?>"> <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="OnButton1(); OnButton2();" alt="PayPal – The safer, easier way to pay online." > <img alt="" align="center" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"></form> </div> <?php exit(); } } echo 'Sorry but we could not find any results.'; } include 'includes/overall/footer.php'; ?>Any help is always appreciated aquaman I cant seem to get these two forms to basically work together.....I need this code(a form submit): Code: [Select] <?php // Where the file is going to be placed $target_path = "uploads/public/uploads/admin/u1p2l3o4a5d6s789/98437e10ec5605a849c3bd9641494560_/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $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!"; } ?> with this code: Code: [Select] <?php if(isset($_POST['save'])) { $event = $_POST['event']; $startdate = $_POST['startdate']; $enddate = $_POST['enddate']; $description = $_POST['description']; $location = $_POST['location']; $month = $_POST['month']; $title1 = $_POST['title1']; $title2 = $_POST['title2']; $title3 = $_POST['title3']; $title4 = $_POST['title4']; $title5 = $_POST['title5']; $title6 = $_POST['title6']; $title7 = $_POST['title7']; $title8 = $_POST['title8']; $date1 = $_POST['date1']; $date2 = $_POST['date2']; $date3 = $_POST['date3']; $date4 = $_POST['date4']; $date5 = $_POST['date5']; $date6 = $_POST['date6']; $date7 = $_POST['date7']; $date8 = $_POST['date8']; $subevent1 = $_POST['subevent1']; $subevent2 = $_POST['subevent2']; $subevent3 = $_POST['subevent3']; $subevent4 = $_POST['subevent4']; $subevent5 = $_POST['subevent5']; $subevent6 = $_POST['subevent5']; $subevent7 = $_POST['subevent6']; $subevent8 = $_POST['subevent7']; $price1 = $_POST['price1']; $price2 = $_POST['price2']; $price3 = $_POST['price3']; $price4 = $_POST['price4']; $price5 = $_POST['price5']; $price6 = $_POST['price6']; $price7 = $_POST['price7']; $price8 = $_POST['price8']; $month2 = $_POST['month2']; $month_num = $_POST['month_num']; $day = $_POST['day']; $year = $_POST['year']; $shutoff = $_POST['shutoff']; if(!get_magic_quotes_gpc()) { $event = addslashes($event); $startdate = addslashes($startdate); $enddate = addslashes($enddate); $description = addslashes($description); $location = addslashes($location); $month = addslashes($month); $title1 = addslashes($title1); $title2 = addslashes($title2); $title3 = addslashes($title3); $title4 = addslashes($title4); $title5 = addslashes($title5); $title6 = addslashes($title6); $title7 = addslashes($title7); $title8 = addslashes($title8); $date1 = addslashes($date1); $date2 = addslashes($date2); $date3 = addslashes($date3); $date4 = addslashes($date4); $date5 = addslashes($date5); $date6 = addslashes($date6); $date7 = addslashes($date7); $date8 = addslashes($date8); $subevent1 = addslashes($subevent1); $subevent2 = addslashes($subevent2); $subevent3 = addslashes($subevent3); $subevent4 = addslashes($subevent4); $subevent5 = addslashes($subevent5); $subevent6 = addslashes($subevent6); $subevent7 = addslashes($subevent7); $subevent8 = addslashes($subevent8); $price1 = addslashes($price1); $price2 = addslashes($price2); $price3 = addslashes($price3); $price4 = addslashes($price4); $price5 = addslashes($price5); $price6 = addslashes($price6); $price7 = addslashes($price7); $price8 = addslashes($price8); $month2 = addslashes($month2); $month_num = addslashes($month_num); $year = addslashes($year); $day = addslashes($day); } include 'config.php'; include 'opendb.php'; $query = "INSERT INTO Registration (event, startdate, enddate, description, location, month, title1, title2, title3, title4, title5, title6, title7, title8, date1, date2, date3, date4, date5, date6, date7, date8, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, price1, price2, price3, price4, price5, price6, price7, price8, month2, shutoff) VALUES ('$event', '$startdate', '$enddate', '$description', '$location', '$month', '$title1', '$title2', '$title3', '$title4', '$title5', '$title6', '$title7', '$title8', '$date1', '$date2', '$date3', '$date4', '$date5', '$date6', '$date7', '$date8', '$subevent1', '$subevent2', '$subevent3', '$subevent4', '$subevent5', '$subevent6', '$subevent7', '$subevent8', '$price1', '$price2', '$price3', '$price4', '$price5', '$price6', '$price7', '$price8', '$month2', '$shutoff')"; mysql_query($query) or die('Error, query failed'); include 'closedb.php'; echo "<pre>".print_r($_POST, true)."</pre>"; } ?> I tried this: Code: [Select] <?php if(isset($_POST['save'])) { $event = $_POST['event']; $startdate = $_POST['startdate']; $enddate = $_POST['enddate']; $description = $_POST['description']; $location = $_POST['location']; $month = $_POST['month']; $title1 = $_POST['title1']; $title2 = $_POST['title2']; $title3 = $_POST['title3']; $title4 = $_POST['title4']; $title5 = $_POST['title5']; $title6 = $_POST['title6']; $title7 = $_POST['title7']; $title8 = $_POST['title8']; $date1 = $_POST['date1']; $date2 = $_POST['date2']; $date3 = $_POST['date3']; $date4 = $_POST['date4']; $date5 = $_POST['date5']; $date6 = $_POST['date6']; $date7 = $_POST['date7']; $date8 = $_POST['date8']; $subevent1 = $_POST['subevent1']; $subevent2 = $_POST['subevent2']; $subevent3 = $_POST['subevent3']; $subevent4 = $_POST['subevent4']; $subevent5 = $_POST['subevent5']; $subevent6 = $_POST['subevent5']; $subevent7 = $_POST['subevent6']; $subevent8 = $_POST['subevent7']; $price1 = $_POST['price1']; $price2 = $_POST['price2']; $price3 = $_POST['price3']; $price4 = $_POST['price4']; $price5 = $_POST['price5']; $price6 = $_POST['price6']; $price7 = $_POST['price7']; $price8 = $_POST['price8']; $month2 = $_POST['month2']; $month_num = $_POST['month_num']; $day = $_POST['day']; $year = $_POST['year']; $shutoff = $_POST['shutoff']; if(!get_magic_quotes_gpc()) { $event = addslashes($event); $startdate = addslashes($startdate); $enddate = addslashes($enddate); $description = addslashes($description); $location = addslashes($location); $month = addslashes($month); $title1 = addslashes($title1); $title2 = addslashes($title2); $title3 = addslashes($title3); $title4 = addslashes($title4); $title5 = addslashes($title5); $title6 = addslashes($title6); $title7 = addslashes($title7); $title8 = addslashes($title8); $date1 = addslashes($date1); $date2 = addslashes($date2); $date3 = addslashes($date3); $date4 = addslashes($date4); $date5 = addslashes($date5); $date6 = addslashes($date6); $date7 = addslashes($date7); $date8 = addslashes($date8); $subevent1 = addslashes($subevent1); $subevent2 = addslashes($subevent2); $subevent3 = addslashes($subevent3); $subevent4 = addslashes($subevent4); $subevent5 = addslashes($subevent5); $subevent6 = addslashes($subevent6); $subevent7 = addslashes($subevent7); $subevent8 = addslashes($subevent8); $price1 = addslashes($price1); $price2 = addslashes($price2); $price3 = addslashes($price3); $price4 = addslashes($price4); $price5 = addslashes($price5); $price6 = addslashes($price6); $price7 = addslashes($price7); $price8 = addslashes($price8); $month2 = addslashes($month2); $month_num = addslashes($month_num); $year = addslashes($year); $day = addslashes($day); } include 'config.php'; include 'opendb.php'; $query = "INSERT INTO Registration (event, startdate, enddate, description, location, month, title1, title2, title3, title4, title5, title6, title7, title8, date1, date2, date3, date4, date5, date6, date7, date8, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, price1, price2, price3, price4, price5, price6, price7, price8, month2, shutoff) VALUES ('$event', '$startdate', '$enddate', '$description', '$location', '$month', '$title1', '$title2', '$title3', '$title4', '$title5', '$title6', '$title7', '$title8', '$date1', '$date2', '$date3', '$date4', '$date5', '$date6', '$date7', '$date8', '$subevent1', '$subevent2', '$subevent3', '$subevent4', '$subevent5', '$subevent6', '$subevent7', '$subevent8', '$price1', '$price2', '$price3', '$price4', '$price5', '$price6', '$price7', '$price8', '$month2', '$shutoff')"; mysql_query($query) or die('Error, query failed'); include 'closedb.php'; echo "<pre>".print_r($_POST, true)."</pre>"; $target_path = "uploads/public/uploads/admin/u1p2l3o4a5d6s789/98437e10ec5605a849c3bd9641494560_/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $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!"; } } ?>but it didn't work..... Ok, so I currently have this http://pastebin.com/cCgyavs0 snippet that generates links to the previous, next and last page based on the current page (GET variable) or the total item count in the MySQL DB to then use forms as links by inserting the URLs into the action attribute. I did this cause I don't wanna use images as links, btw :P It kinda works - I get links like: shop.php?page=1 shop.php?page=12 shop.php?page=14 shop.php?page=225 When I'm on page 13 of 225 for example. Though when I click one of the buttons, I always get redirected to "shop.php?". :/ Hello, I have a .htaccess file set up to create directories and files based on my PHP variables. That's how it looks anyway. It's really just some URL rewriting. I'm looking to submit a form and use the code on the same page to handle the form via isset(). The problem is, however, that $_SERVER['PHP_SELF']; redirects me back to the original base/index.php page, while nothing gets submitted. I can sort of see why, but is there any way to overcome it? I could probably use the actual file and variable names, but that isn't very practical as I intend on using this code as a basis for a much larger scale. I'm not too fond of using external pages as sources for the form action either for the same reason. My intentions were to have everything handled on a single page. Also, feel free to post constructive criticism on how to improve the code. I'm rather new to PHP and will need all the help I can get. .htaccess code Code: [Select] RewriteRule base/([a-zA-Z]+)/$ base/index.php?cat=$1 RewriteRule base/([a-zA-Z]+)/([a-zA-Z0-9]+)\.php$ base/index.php?cat=$1&subcat=$2 index.php code Code: [Select] <html> <head> <title>Index</title> </head> <body> <?php $cat=$_GET['cat']; $subcat=$_GET['subcat']; if (isset($cat)){ if ($cat=='foo'){ if (isset($subcat)){ if($subcat=='bar'){ if (isset($_POST['submit'])) { echo 'Entry Submitted Successfully'; } else{ ?> <h1>Add an Entry</h1> <div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> <span>Field:</span> <span><input type="text" size="15" /></span> </div> <div> <input name="submit" type="submit" value="Submit" /> </div> </form> </div> <p> <a href="/base/">Return to Base Page</a> </p> <?php } } else { echo 'Error: Not a valid sub-category.'; } } else { ?> <h1>Select an Option</h1> <ul> <li><a href="bar.php">Add Entry</a></li> </ul> <p> <a href="/base/">Return to Base Page</a> </p> <?php } } else { echo 'Error: Not a valid Category.'; } } else{ ?> <h1>Base Page</h1> <h2><a href="foo/">Go to "Select an Option" page</a></h2> <ul> <li><a href="foo/bar.php">Go to "Add an Entry" page</a></li> </ul> <?php } ?> </div> </body></html> Hey guys, I'll be the first to say that I'm a real php n00b, and only understand the basics. I have a website already in place that someone else coded and I just need to add something to. There's a form that posts to another page and then back to a sql database. What I want to do is have the form also email me the contents of the form when it is submitted. Is there a way to have a form do multiple actions? I'm not sure the best way to go about this, so if someone has some pointers, I'd really appreciate it. Thanks! I don't have any PHP skills at all. In fact I'm probably looking for a script that can help accomplish what I'm asking about. Regardless, I'm having a hard time getting any answers or solutions to this. I would like to make a web form that collects cc#'s from my customers that is PCI Compliant in as simple a manner as possible. 99% of the time my clients are not being charged at all, and the cc is used simply to ensure a service is confirmed. If they were to be charged, I would have to do that manually as no payment gateways currently deposit into banks in the country I am in. One thought I had would be if I could have the cc# either split, or broken up into separate fields and emailed separately. I am told this is PCI Compliant. I would also be fine with the cc# being split between database and email. I know this is possible w/ zen cart, but I have been unable to find any scripts that do this and don't have a need for a shopping cart addition to my site. But, I am aware that zen cart and other shopping cart add ons have options for X's to cover a bunch of numbers in the middle of the string and write that directly to the database. One thing that is a necessity is that the majority of the data input to the form be emailed. So, I'm basically hoping to protect the cc data in the simplest way possible, which I thought would be to break it up. I'll be trashing the cc #'s once I get them. I have no need to file them. I do have a SSL on my server. I am completely open to other suggestions. Is something like this, or another option a possibility? My skills are rudimentary. I taught myself to write some html and also use Dreamweaver to subsidize for what I can't code myself. I apologize if this should be in one of the other forums. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=321767.0 Im using dreamweaver, and I have a simple list menu that is linked to a dynamic source in my database. I cannot figure out how to create an action when they select something from the list menu. I suppose that it would have to be passed through the browser somehow. Im not very code fluent, but I try. If you know to accomplish this using dreamweaver cs4 or hard coding, I would appreciate it. I want this: When you click on an item it will bring up all the data pertaining to that particular record. My code: Code: [Select] <form id="form1" name="form1" method="post" action=""> <label for="customerlist">Select your customers</label> <p><label for="customers"></label> <select name="customers" id="customers"> <option value="None">None</option> <?php do { ?> <option value="<?php echo $row_Customers['name']?>"><?php echo $row_Customers['name']?></option> <?php } while ($row_Customers = mysql_fetch_assoc($Customers)); $rows = mysql_num_rows($Customers); if($rows > 0) { mysql_data_seek($Customers, 0); $row_Customers = mysql_fetch_assoc($Customers); } ?> </select> <input type="submit" name="Go" id="Go" value="Go" /> I created an app for my website, set action (read) and object (article), and placed the objects code (META tags in the head) at the article page on my website. Now, I want to know how to send a cUrl request whenever a user reads an article on my website, so it'll feature on his wall. When I press the "get code" link near the action, that's what I get: Code: [Select] curl -F 'access_token=***' \ -F 'article=http://example.com' \ 'https://graph.facebook.com/me/yellowheart:read' (There's an actual access token of course). Now, how do I make it happen? Daniel Hi Guys, I'm having some trouble running PHP scripts. I have two forms, each of which redirects to a PHP script (each PHP script is different, but essentially both have the same problem) as an action. The code is below. I'm hosted at Bluehost, which runs PHP on their servers so I know the tech is compatible. Thanks! Cheers! <html> <script type="text/php">include('newform.php');</script> <head> <title>TradeSquared></title> <p align="center">Trade Squared</p> </head> <body> <br> <br> <div align="center"> Create a new Listing: <form action="newform.php" method="get" name="newform"> Type:<select name="type"> <option value="book">Book</option> <option value="apt">Apartment</option> <option value="item">Class Items</option> </select> <input type="submit" value="Submit"/> </form> <br> Search current Listings: <form action="searchform.php" method="get" name="searchform"> Type:<select name="type"> <option value="book">Book</option> <option value="apt">Apartment</option> <option value="item">Class Items</option> </select> <input type="submit" value="Submit"/> </form> </div> </body> </html> This is the PHP code on which action redirects to <?php $type = $_GET=["type"]; if($type=="book") header("location:addbooklisting.html"); else if($type == "apt") header("location:aptform"); else header("location:itemform"); ?> Second page <html> <head> <title>Create New Book Listing</title> <p align="center"> <b>Create a New Book Listing</b> </p> </head> <body> <div align="center"> <br><br> <form name="addlisting" method="get" action="bookvalidation.php"> <table width="100" border="0" align="center"> <tr> <td align="center">Title </td> </tr> <tr> <td align="center"><input type="text" name="title"/> </td> </tr> <tr><td><p/></td></tr> <tr> <td align="center">Price </td> </tr> <tr> <td align="center">$<input type="text" name="dollars" size="3"/>.<input type="text" name="cents" size="2"/> </td> </tr> <tr><td><br></td></tr> <tr> <td align="center">ISBN</td> </tr> <tr> <td align="center"><input type="text" name="isbn"/></td> </tr> <tr><td><br></td></tr> <tr> <td align="center">Condition </td> </tr> <tr> <td align="center"><select name="cond"> <option name="used">Used</option> <option name="new">New</option> </select> </td> </tr> <tr><td><br></td></tr> <tr> <td align="center">Commentaries </td> </tr> <tr> <td align="center"><textarea rows="5" cols="30" name="comm"></textarea></td> </tr> <tr><td><br></td></tr> <tr> <td align="center"><input type="submit" value="Add Listing"/></td> </tr> </table> </form> </div> </body> </html> PHP code for second page <html> <head>Results</head> <body> The Following Occurred: <?php $title = $_GET["title"]; $dollar = $_GET["dollars"]; $cents = $_GET["cents"]; $price = $dollar.".".$cents $isbn = $_GET["isbn"]; $cond = $_GET["cond"]; $decide; $comments = $_GET["comm"]; for($i=0; $i<=12; i++) { if(ctype_digit($isbn)) $decide = true; else $decide = false; } if( !(($dollar && $cents)==int) ) echo "Price must be in numbers."; else if($decide == false || strlen($isbn)!=13) echo "ISBN contains 13 characters and must be numbers only" else { $db=mysql_connect("localhost","username","pass!"); mysql_select_db("db_dataabse",$db); $dbsucces=mysql_query("INSERT INTO BookListings (Title, ISBN, Price, Condition, Comments) VALUES ('$title', '$isbn', '$price', '$cond', '$comments')"); if($dbsuccess==true) echo "Posting was succesful"; else echo"Unsuccesful log."; } ?> </body> </html> Hello, I have coded a contact form in PHP and I want to know, if according to you, it is secure! I am new in PHP, so I want some feedback from you. Moreover, I have also two problems based on the contact form. It is a bit complicated to explain, thus, I will break each of my problem one by one. FIRST:The first thing I want to know, is if my contact form secure according to you: The HTML with the PHP codes: Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Assigning variables to elements $first = htmlentities($_POST['first']); $last = htmlentities($_POST['last']); $sub = htmlentities($_POST['subject']); $email = htmlentities($_POST['email']); $web = htmlentities($_POST['website']); $heard = htmlentities($_POST['heard']); $comment = htmlentities($_POST['message']); $cap = htmlentities($_POST['captcha']); //Declaring the email address with body content $to = 'alithebestofall2010@gmail.com'; $body ="First name: '$first' \n\n Last name: '$last' \n\n Subject: '$sub' \n\n Email: '$email' \n\n Website: '$web' \n\n Heard from us: '$heard' \n\n Comments: '$comment'"; //Validate the forms if (empty($first) || empty($last) || empty($sub) || empty($email) || empty($comment) || empty($cap)) { echo '<p class="error">Required fields must be filled!</p>'; header ('refresh= 3; url= index.php'); return false; } elseif (filter_var($first, FILTER_VALIDATE_INT) || filter_var($last, FILTER_VALIDATE_INT)) { echo '<p class="error">You cannot enter a number as either the first or last name!</p>'; return false; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<p class="error">Incorrect email address!</p>'; return false; } elseif (!($cap === '12')){ echo '<p class="error">Invalid captcha, try again!</p>'; return false; } else { mail ($to, $sub, $body); echo '<p class="success">Thank you for contacting us!</p>'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Your first name: <span class="required">*</span></p> <p><input type="text" name="first" size="40" placeholder="Ex: Paul"/></p> <p>Your last name: <span class="required">*</span></p> <p><input type="text" name="last" size="40" placeholder="Ex: Smith"/></p> <p>Subject: <span class="required">*</span></p> <p><input type="text" name="subject" size="40" placeholder="Ex: Contact"/></p> <p>Your email address: <span class="required">*</span></p> <p><input type="text" name="email" size="40" placeholder="Ex: example@xxx.com"/></p> <p>Website:</p> <p><input type="text" name="website" size="40" placeholder="Ex: http//:google.com"/></p> <p>Where you have heard us?: <span class="required">*</span></p> <p><select name="heard"> <option>Internet</option> <option>Newspapers</option> <option>Friends or relatives</option> <option>Others</option> </select></p> <p>Your message: <span class="required">*</span></p> <p><textarea cols="75" rows="20" name="message"></textarea></p> <p>Are you human? Sum this please: 5 + 7 = ?: <span class="required">*</span></p></p> <p><input type="text" name="captcha" size="10"/></p> <p><input type="submit" name="submit" value="Send" class="button"/> <input type="reset" value="Reset" class="button"/></p> </form> SECOND PROBLEM:If a user has made a mistake, he gets the error message so that he can correct! However, when a mistake in the form occurs, all the data the user has entered are disappeared! I want the data to keep appearing so that the user does not start over again to fill the form. THIRD: When the erro message is displayed to notify the user that he made a mistake when submitting the form, the message is displaying on the top of the page. I want it to appear below each respective field. How to do that? In JQuery it is simple, but in PHP, I am confusing! Stumped! I have a client who has a form where they upload files to their server: title, two password fields, and the file
They have been unable to upload anything over 10m
Small (under 10mb) files work.
Larger doesn’t
I’ve tracked it down, I think, that the processing page appears to be dropping the form values when the file takes a bit to upload.
I echo’ed the values that are grabbed from the form, and they return empty strings if it takes a while for the file to upload (a large file) - they pass fine if the file is smaller.
I think I've got the php info set correctly, but cannot for the life of me figure out how to adjust the timing out issue, or even where to troubleshoot.
Here's my phpinfo:
Max Requests
Per Child: 750 - Keep Alive: off - Max Per Connection: 100
Timeouts
Connection: 120 - Keep-Alive: 5
Directive
Local Value
Master Value
allow_call_time_pass_reference
Off
Off
allow_url_fopen
On
On
allow_url_include
Off
Off
always_populate_raw_post_data
Off
Off
arg_separator.input
&
&
arg_separator.output
&
&
asp_tags
Off
Off
auto_append_file
no value
no value
auto_globals_jit
On
On
auto_prepend_file
no value
no value
browscap
/etc/browscap.ini
/etc/browscap.ini
default_charset
no value
no value
default_mimetype
text/html
text/html
define_syslog_variables
Off
Off
disable_classes
no value
no value
disable_functions
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
display_errors
Off
Off
display_startup_errors
Off
Off
doc_root
no value
no value
docref_ext
no value
no value
docref_root
no value
no value
enable_dl
Off
Off
error_append_string
no value
no value
error_log
/mnt/Target01/337846/945285/www.dermerrealestate.com/logs/php_errors.log
no value
error_prepend_string
no value
no value
error_reporting
30711
30711
exit_on_timeout
Off
Off
expose_php
Off
Off
extension_dir
/usr/lib64/php/modules
/usr/lib64/php/modules
file_uploads
On
On
highlight.bg
#FFFFFF
#FFFFFF
highlight.comment
#FF8000
#FF8000
highlight.default
#0000BB
#0000BB
highlight.html
#000000
#000000
highlight.keyword
#007700
#007700
highlight.string
#DD0000
#DD0000
html_errors
On
On
ignore_repeated_errors
Off
Off
ignore_repeated_source
Off
Off
ignore_user_abort
Off
Off
implicit_flush
Off
Off
include_path
.:/usr/share/pear:/usr/share/php
.:/usr/share/pear:/usr/share/php
log_errors
On
On
log_errors_max_len
1024
1024
magic_quotes_gpc
On
On
magic_quotes_runtime
Off
Off
magic_quotes_sybase
Off
Off
mail.add_x_header
On
On
mail.force_extra_parameters
no value
no value
mail.log
no value
no value
max_execution_time
30
30
max_file_uploads
20
20
max_input_nesting_level
64
64
max_input_time
60
60
max_input_vars
1000
1000
memory_limit
128M
128M
open_basedir
no value
no value
output_buffering
no value
no value
output_handler
no value
no value
post_max_size
8M
8M
precision
14
14
realpath_cache_size
4M
4M
realpath_cache_ttl
120
120
register_argc_argv
On
On
register_globals
Off
Off
register_long_arrays
On
On
report_memleaks
On
On
report_zend_debug
On
On
request_order
no value
no value
safe_mode
Off
Off
safe_mode_exec_dir
no value
no value
safe_mode_gid
Off
Off
safe_mode_include_dir
no value
no value
sendmail_from
no value
no value
sendmail_path
/usr/sbin/sendmail -t -i
/usr/sbin/sendmail -t -i
serialize_precision
100
100
short_open_tag
On
On
SMTP
localhost
localhost
smtp_port
25
25
sql.safe_mode
Off
Off
track_errors
Off
Off
unserialize_callback_func
no value
no value
upload_max_filesize
8M
8M
upload_tmp_dir
/tmp
/tmp
user_dir
no value
no value
user_ini.cache_ttl
300
300
user_ini.filename
.user.ini
.user.ini
variables_order
EGPCS
EGPCS
xmlrpc_error_number
0
0
xmlrpc_errors
Off
Off
y2k_compliance
On
On
zend.enable_gc
On
On
I have read around and can't seem to find the right coding for what I need on this forum and some other other forums. I have a contact form (as listed below) and I need 2 locations (Print Name and Title) fields to auto-populate on a separate form (can be a doc, pdf, etc. any form of document which is easiest) and this form can be totally back end and the individual using the form never is going to see the form. It's going on a contract form, that we would like to auto-populate. Also is there a simple attachment code so individuals can attach documents to the code? <p style: align="center"><form action="mailtest.php" method="POST"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> <div align="center"> <p class="style1">Name</p> <input type="text" name="name"> <p class="style1">Address</p> <input type="text" name="address"> <p class="style1">Email</p> <input type="text" name="email"> <p class="style1">Phone</p> <input type="text" name="phone"> <p class="style1">Debtor</p> <input type="text" name="debtor"> <p class="style1">Debtor Address</p> <input type="text" name="debtora"> <br /> <br /> <a href="authoforms.php" target="_blank" style="color:#ffcb00" vlink="#ffcb00">Click here to view Assignment Agreement and Contract Agreement</a> <p class="style1"><input type='checkbox' name='chk' value='I Have read and Agree to the terms.'> I have read and agree to the Assignment and Contract Agreement <br></p> <p class="style1">Print Name</p> <input type="text" name="pname"> <p class="style1">Title</p> <input type="text" name="title"> <p class="style1">I hear by agree that the information I have provided is true, accurate and the information I am submitting is <br /> not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms:</p> <select name="agree" size="1"> <option value="Agree">Agree</option> <option value="Disagree">Disagree</option> </select> <br /> <br /> <p class="style1">Employee ID:</p> <input type="text" name="employee"> <br /> <input type="submit" value="Send"><input type="reset" value="Clear"> </div> </form> </p> The mailtest php is this ?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; $phone = $_POST['phone']; $debtor = $_POST['debtor']; $debtora = $_POST['debtora']; $value = $_POST['chk']; $pname = $_POST['pname']; $title = $_POST['title']; $agree = $_POST['agree']; $employee = $_POST['employee']; $formcontent=" From: $name \n Address: $address \n Email: $email \n Phone: $phone \n Debtor: $debtor \n Debtor's Address: $debtora \n 'Client' has read Assignment and Contract Agreement: $value \n Print Name: $pname \n Title: $title \n I hear by agree that the information I have provided is true, accurate and the information I am submitting is not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms: $agree \n \n Employee ID: $employee \n IP: $ip"; $recipient = "mail@crapower.com"; $subject = "Online Authorization Form 33.3%"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!" . " -" . "<a href='index.php' style='text-decoration:none;color:#ffcb00;'> Return Home</a>"; $ip = $_POST['visitoraddress'] ?> Hello, first time poster.. I've looked the web over for a long time and can't figure this one out. - Below is basic code that successfully checks MySQL for a match and displays result. I was debugging and forced the "height" and "width" to be 24 and 36 to make sure that wasn't the problem. That's good.. - I'd like to give the user ability to select width and height from a form.. and have it do an onchange this.form.submit so the form can be changing as fields are altered (thus the onchange interaction) - In a normal coding environment I've done this numerous times with no "Page cannot be displayed" problems. It would simply change one select-option value at a time til they get down the form and click submit... but in WordPress I'm having trouble making even ONE single onchange work! - I've implemented the plugins they offer which allows you to "copy+paste" your php code directly into their wysiwyg editor. That works with basic tests like my first bullet point above. - I've copied and pasted the wordpress url (including the little ?page_id=123) into the form "action" url... that didn't work... tried forcing it into an <option value=""> tag.. didn't work. I'm just not sure. I've obviously put xx's in place of private info.. Why does this form give me Page Cannot Be Displayed in WordPress every time? It won't do anything no matter how simple.. using onchange.. Code.. $con = mysql_connect("xxxx.xxxxxxx.com","xxxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $myprodwidth=24; $myprodheight=36; $result = mysql_query("SELECT * FROM product_sizes WHERE prodwidth='$myprodwidth' and prodheight='$myprodheight'"); while($row = mysql_fetch_array($result)) { echo $row['prodprice']; } mysql_close($con); <form method="post" action=""> <select name="myheight" onchange="this.form.submit();"> <option selected="selected" value="">select height</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">36</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">48</option> </select> There are two pieces to this- The HTML Form and the resulting php. I can't seem to make the leap, from the code to having the form produce the php page so others can view it until the form is again submitted overwriting the php, thus generating new content. The environment I am working in is limited to IIs 5.1 and php 5.2.17 without mySQL or other DB I'm new to php, this isn't homework,or commercialization, it's for children. I am thinking perhaps fwrite / fread but can't get my head around it. Code snipets below. Any help, please use portions of this code in hopes I can understand it Thanks Code snipet from Output.php Code: [Select] <?php $t1image = $_POST["t1image"]; $t1title = $_POST["t1title"]; $t1info = $_POST["t1info"]; $t2image = $_POST["t2image"]; $t2title = $_POST["t2title"]; $t2info = $_POST["t2info"]; ?> ... <tbody> <tr><!--Headers--> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Animal</td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Image thumb<br> </td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Date<br> </td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Information<br> </td> </tr> <tr> <td style="vertical-align: top; text-align: center;">Monkey </td> <td style="vertical-align: top; text-align: center;"><img src="<?php echo $t1image.'.gif'; ?>"><!--single image presented selected from radio buttons--> </td> <td style="vertical-align: top; text-align: center;"><?php echo date("m/d/Yh:i A"); ?><!--time stamp generated when submitted form populates all fields at once--> </td> <td style="vertical-align: top; text-align: center;"><a href="#monkey" rel="facebox"><?php echo $t1title ?></a><!--Link name provided by "Title 1", that links to hidden Div generated page with content from "Info1" field--> <div id="Monkey" style="display:none"> <?php echo $t1info; ?> </div> </td> </tr> <tr> <td style="vertical-align: top; text-align: center;">Cat<br> </td> <td style="vertical-align: top; text-align: center;"><img src="<?php echo $t2image.'.gif'?>"></td> <td style="vertical-align: top; text-align: center;"><?php echo date("m/d/Yh:i A"); ?></td> <td style="vertical-align: top; text-align: center;"><a href="#Cat" rel="facebox"><?php echo $t2title ?></a> <div id="Cat" style="display:none"> <?php echo $t2info; ?> </div> </td> </tr> <tr> This replicates several times down the page around 15-20 times ( t1### - t20###) Code Snipet from HTML Form Code: [Select] <form action="animals.php" method="post"> <div style="text-align: left;"><big style="font-family: Garamond; font-weight: bold; color: rgb(51, 51, 255);"><big><big><span>Monkey</span></big></big></big><br> <table style="text-align: left; width: 110px;" border="0" cellpadding="2" cellspacing="0"> <tbody><tr> <td style="vertical-align: top;">Image thumb<br> <input type="radio" name="t1image" value="No opinion" checked><img src="eh.gif" alt="Eh"> <input type="radio" name="t1image" value="Ok"><img src="ok.gif" alt="ok"> <input type="radio" name="t1image" value="Like"><img src="like.gif" alt="Like"> <input type="radio" name="t1image" value="Dont"><img src="dont.gif" alt="Don't Like"> <input type="radio" name="t1image" value="Hate"><img src="hate.gif" alt="Hate"> <input type="radio" name="t1image" value="Other"><img src="other.gif" alt="Other"> <br> Why Title:<input type="text" name="t1title" size="45" value="..."/></td> <td style="vertical-align: top;"> Explain:<br> <textarea name="t1info" cols=45 rows=3 value="..."></textarea> </td></tr></table> <br> <!--Next--> How do I get the Form data to save to the php page for others to view? Hi 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 ?> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347360.0 I'm not sure why, but once I added a search form in my nav menu, it made my other forms on the website such as login and signup form take them to where the search button would take them. any ideas??? Hi i am trying to change the query to sort by desc or asc I am using the switch method but the form is not calling the switch statment can someone help me out please? this is the swicth script Code: [Select] switch ($sortby) { case "ASC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'ASC', 'paged' => get_query_var('paged') ); break; case "DESC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'DESC', 'paged' => get_query_var('paged') ); break; }This is the form Code: [Select] <form name="myForm"> <select id="sortby" > <option value="ASC">ASC</option> <option value="DESC">DESC</option> </select> </form> I intend to use a onchange so that when depending on the option they select it will change the order? Hi- the code below lets me upload a CSV file to my database if I have 1 field in my database and 1 column in my CSV. I need to add to my db "player_id" from the CVS file and "event_name" and "event_type" from the form... any ideas??? here's the code: Code: [Select] <?php $hoststring =""; $database = ""; $username = ""; $password = ""; $makeconnection = mysql_pconnect($hoststring, $username, $password); ?> <?php ob_start(); mysql_select_db($database, $makeconnection); $sql_get_players=" SELECT * FROM tabel ORDER BY player_id ASC"; // $get_players = mysql_query($sql_get_players, $makeconnection) or die(mysql_error()); $row_get_players = mysql_fetch_assoc($get_players); // $message = null; $allowed_extensions = array('csv'); $upload_path = '.'; //same directory if (!empty($_FILES['file'])) { if ($_FILES['file']['error'] == 0) { // check extension $file = explode(".", $_FILES['file']['name']); $extension = array_pop($file); if (in_array($extension, $allowed_extensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_path.'/'.$_FILES['file']['name'])) { if (($handle = fopen($upload_path.'/'.$_FILES['file']['name'], "r")) !== false) { $keys = array(); $out = array(); $insert = array(); $line = 1; while (($row = fgetcsv($handle, 0, ',', '"')) !== FALSE) { foreach($row as $key => $value) { if ($line === 1) { $keys[$key] = $value; } else { $out[$line][$key] = $value; } } $line++; } fclose($handle); if (!empty($keys) && !empty($out)) { $db = new PDO( 'mysql:host=host;dbname=db', 'user', 'pw'); $db->exec("SET CHARACTER SET utf8"); foreach($out as $key => $value) { $sql = "INSERT INTO `table` (`"; $sql .= implode("`player_id`", $keys); $sql .= "`) VALUES ("; $sql .= implode(", ", array_fill(0, count($keys), "?")); $sql .= ")"; $statement = $db->prepare($sql); $statement->execute($value); } $message = '<span>File has been uploaded successfully</span>'; } } } } else { $message = '<span>Only .csv file format is allowed</span>'; } } else { $message = '<span>There was a problem with your file</span>'; } } ob_flush();?> <!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=UTF-8" /> <title>CSV File Upload</title> </head> <body> <form class="form" action="" method="post" enctype="multipart/form-data"> <h3>Select Your File</h3> <p><?php echo $message; ?></p> <input type="file" name="file" id="file" size="30" /> <br/> <label>Event Name:</label><input name="event_name" type="text" value="" /> <br/> <label>Event Type:</label><input name="event_type" type="text" value="" /> <br/> <input type="submit" id="btn" class="button" value="Submit" /> </form> <br/> <h3>Results:</h3> <?php do { ?> <p><?php echo $row_get_players['player_id'];?></p> <?php } while ($row_get_players = mysql_fetch_assoc($get_players)); ?> </body> </html> |