PHP - Form Post - Posting Invalid Information
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. Similar TutorialsHi 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. hi guys, the problem is, is that all of the code works fine, however im trying to post the user to the leader board (leaders.xml) however it just isnt adding to the xml page and im not too sure why. I attached all 3 files that you may need to see to figure it out. Hope you can really help, I would really appreciate it. Okay this section is the index where the user enters their user name Code: [Select] <?php session_name("elearning_Test"); session_start(); $_SESSION['score'] = 0; $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; $_SESSION['num'] = 0; require_once ('functions.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <script type="text/javascript" src="start.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="leaderboard.php">Leader Board</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Forensics E-Learning Package</h1><BR /> <h2>Start The Test</h2> <form id="questionBox" method="post" action="home.php"> <label for="username">Create A Username:</label><br /> <input type="text" id="username" name="username" value="Username" /> <p id="exp">Username must be between 3 and 10 characters in length</p></li> </ul> <p><input type="hidden" name="register" value="TRUE" /> <input type="submit" id="submit" value="Register And Take The Test" /></p> </form> <p id="helper"><?php if(isset($_SESSION['error'])) echo $_SESSION['error']; ?></p> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="leaderboard.php">Leader Board</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"> <p id="legal"> </p> </div> </div> </div> </body> </html> This section is the leaderboardpage Code: [Select] <?php session_name("elearning_Test"); session_start(); include_once('functions.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="index.php">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="index.php">About</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Leader Board</h1> <h2>Top Scorers</h2> <?php echo "Welcome to the Leaderboard " . $_SESSION['user']; ?><BR /><BR /> <?php showLeaders('leaders.xml',20); ?><BR /><BR /> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="index.php">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="index.php">About</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"> <p id="legal"> </p> </div> </div> </div> </body> </html> And finally this section is the functions page. Code: [Select] <?php // shuffle answers function shuffle_assoc($array) { $keys = array_keys($array); shuffle($keys); $shuffled = array(); foreach ($keys as $key) $shuffled[$key] = $array[$key]; return $shuffled; } // leader board section function showLeaders($file,$limit,$group = null) { $leaders = array(); // Load the xml file and place all users and associated // scores into the 'leaders' array. $xml = simplexml_load_file($file); foreach($xml->user as $user) { $name = (string)$user->name; $score = (string)$user->score; $leaders[$name] = $score; } // Sort the leaders array numerically, highest scorers first. arsort($leaders,SORT_NUMERIC); // Initialise our $counter variable to '1'. $counter = 1; // Start a html ordered list to hold the leaders. $output = "<ul class=\"leaders\">\n"; // Loop through the 'leaders' array and wrap each username and score // in <li> tags. If the user is the current $_SESSION['user'], wrap // the name/score in <strong> tags too. foreach ($leaders as $key => $value) { // Check that $counter is less than $limit. if ($counter <= $limit) { if ($key == $_SESSION['user']) { $output .= "<li><strong>$key:</strong> $value/20</li>\n"; } else { $output .= "<li>$key: $value/20</li>\n"; } // Check to see if $group parameter has been passed. // If it has, create separate lists according to the $group variable. if ($group) { // Use the modulus operator(%) to create new sub-list. if($counter % $group == 0) { $output .= "</ul>\n<ul class=\"leaders\">\n"; } } } // Increment the $counter. $counter++; } // End the ordered list. $output .= "</ul>\n"; // Print out the ordered list. echo $output; } function showAnswers($answers,$questions) { for($x = 0; $x< count($answers); $x++) { if ($x % 2 == 0) { $output = "<div class=\"qanda clear\">\n"; } else { $output = "<div class=\"qanda\">"; } $output .= '<h4>Question' . ($x+1) . ': ' . $questions[$x] . '</h4>'; $output .= "<ol>\n"; for ($y = 0;$y< count($answers[$x]); $y++) { if (($answers[$x][$y] === $answers[$x][0]) && (in_array($answers[$x][$y],$_SESSION['correct']))) { $output .= "<li class=\"correctuser\">{$answers[$x][$y]} (Correct!)</li>\n"; } else if ($answers[$x][$y] === $answers[$x][0]) { $output .= "<li class=\"correct\">{$answers[$x][$y]}</li>\n"; } else if (in_array($answers[$x][$y],$_SESSION['wrong'])) { $output .= "<li class=\"wrong\">{$answers[$x][$y]} (Woops!)</li>\n"; } else { $output .= "<li>{$answers[$x][$y]}</li>\n"; } } $output .= "</ol></div>\n"; echo $output; } } ?> Thanks guys for your help. Just really need another pair of eyes on this as i cant see why. Lance I have created a search facility for a small asset database that is currently hosted locally on my PC using PHP5.3.8, Apache 2.2.2.1 and MySQL 5.0.8. I have two .php pages - search_computers.php and search_computers_sql.php The problem I have is that when I search for e.g. Dell on search_computers.php the web browser opens search_computers_sql.php and displays all of the code and comments on that page from "echo "<p>You forgot to enter" onwards. I have posted the code on both pages below and attached a screenshot of what search_computers_sql.php looks like after submitting a search parameter. This has completely baffled me! I have other forms on this database that have posted and inserted into the MySQL database fine. I've tested the SQL on search_computers_sql.php and that definitely works (I tested it on MySQL query browser). If I was too hazard a guess I would say something isn't quite right with if (isset($_POST['search'])) on search_computers_sql.php but I can't figure it out. Could it possibly be an Apache configuration problem as well? Any help would be much appreciated! search_computers.php Code: [Select] <h2>Search for a Computer</h2> <p>Please enter a search parameter to find a computer<u><b></b></u></p> <br> <form name="search" method="post" action="./search_computers_result.php"> Seach for: <input type="text" name="find" /> under <Select NAME="field"> <Option VALUE="pc_id">PC ID</option> <Option VALUE="manufacturer">Manufacturer</option> <Option VALUE="ram">RAM</option> <Option VALUE="specification">Specification</option> <Option VALUE="network_point">Network Point</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> search_computers_sql.php Code: [Select] //This is only displayed if they have submitted the form if (isset($_POST['search'])) $find = $_POST['find']; $field = $_POST['field']; { //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search parameter. Please click "?><a href="./search_computers_result.php">here</a></li><? echo" to try again."; exit; } // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Connect to local db $data_db = mysqli_connect('localhost','root'); $data = "SELECT c.pc_id, c. manufacturer, c.ram, c.specification, n.network_point, s.status, l.location FROM asset_db.computers c, asset_db.location l, asset_db.network_point n, asset_db.status s WHERE l.id = c.location AND n.id = c.network_point AND s.id = c.status AND upper($field) LIKE '%$find%'"; $result = mysqli_query($data_db,$data); if (!$result) { echo 'There is no data to display'; exit; } //And we remind them what they searched for echo "<b>You Searched For:</b> " .$find; echo "<br>"; echo "<br>"; //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches = mysqli_num_rows($result); if ($anymatches > 0) { echo (' </table> <table> <tr> <th style="width: 75px">PC ID</th> <th style="width: 125px">Manufacturer</th> <th style="width: 75px">RAM</th> <th style="width: 175px">Specification</th> <th style="width: 85px">Network Point</th> <th style="width: 75px">Status</th> <th style="width: 175px">Location</th> </tr>'); echo "Please click "?><a href="./search.php">here</a></li><? echo" to enter a new search parameter.<br><br>"; //And we display the results while($row=mysqli_fetch_array($result,MYSQLI_BOTH)) { $pc_id = $row['pc_id']; $manufacturer = $row['manufacturer']; $ram = $row['ram']; $specification = $row['specification']; $network_point = $row['network_point']; $status = $row['status']; $location = $row['location']; echo "<tr>"; echo "<td>$pc_id</td>"; echo "<td>$manufacturer</td>"; echo "<td>$ram</td>"; echo "<td>$specification</td>"; echo "<td>$network_point</td>"; echo "<td>$status</td>"; echo "<td>$location</td>"; echo "</tr>"; } echo ' </table>'; }// End of $anymatches if ($anymatches == 0) { echo "Sorry, but we cannot find a match for your search. Please click "?><a href="./search_computers.php">here</a></li><? echo" to try again.<br><br>"; } }//End of if (isset($_POST['search'])) [attachment deleted by admin] Hi,
Webapp noob here.
I have an application that is going to be data-heavy, so I would like to avoid saving things to the database whenever possible. The application in a nutshell is an android application wired up to a php web app(with MySQL) where you can send requests to the phone and the phone will respond with text or image data with POST.
The normal way to do this would be for the phone to post the data to the database, then have the webapp display it. However, what im wondering is if it is possible for a user on the webapp to request information from the phone, and then when the phone replies using a POST to display the information temporarily in maybe a popup window instead of having to save it to the database.
Thanks!
Hey Guys. I am working with a form that shows the grand total on the checkout page. The value of the grand total is inside a hidden field. When click on submit, the _POST array doesn't get back the last value of the grand total. I need to hit the button twice to get the last value. The weird thing is when I echo the value of the grand total it display the latest value, but not with the POST array
For example. If the grand total is $10.00 and I click on submit. It will show the POST['grand_total'] as empty. If I click on submit again it will show the grand total of $10.00.
Below is my code that I am working with. Any help would be really appreciated.
if(isset($_POST['submit'])) { /* Doesn't show if i put it after if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } } //A bunch of other html/php code. Another class calculates the subtotal assigns it the variable $subtotal $cart_totals = new cartTotals($subtotal, $discounted_amount,$post_values->tip); // Cart class is shown below /* Doesn't show if i put it before if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } echo "<input name='grand_total' type='hidden' value='$cart_totals->grand_total' />"; // Shows the grand total after second from submission echo "$cart_totals->grand_total"; // Shows grand total after the first submissionCart Totals Class class cartTotals { public $subtotal; public $sales_tax; public $tip; public $grand_total; public $discount_amount; public $href_page; public $invalidCouponMessage; const TEST_ENVIORMENT = FALSE; /** * [ Function gets constructed in the order summary where the [$discount_amount= ""] arg does need to be passed. * But does get passed in when called on the checkout.php page. Therefore we set the default value to an empty string.] * @param [float] $subtotal [subtotal get passed in from the parent class coreCartFunction] * @param string $discount_amount [The class checkCouponCode calculates this discount amount based on the * subtotal and the discount amount. It gets instantiated on the clients side and passed is this construction function. * This is all done on the checkout page.] */ /*The way the construct function works is by invoking all the methods the passed arguments When the methods get invoked the do all the work and set the properties its values. The properties then get echoed out on the client side. */ function __construct($subtotal="", $discount_amount= "", $tip=""){ $this->subTotal($subtotal, $discount_amount);//SubTotal method takes the discount amount and subtracts it from the subtotal. $this->salesTax($subtotal, $discount_amount); $this->tip = $tip; $this->grandTotal(); } private function subTotal($subtotal,$discount_amount) { $rounded_subtotal = round($subtotal-$discount_amount,2); $money_format_subtotal = money_format('%i',$rounded_subtotal); $this->subtotal = $money_format_subtotal; } private function salesTax($subtotal, $discount_amount =""){ $sales_tax = (STORE_SALES_TAX)?(float)STORE_SALES_TAX:8.875; $sales_tax =(($this->subtotal)*$sales_tax)/100; $sales_tax = round($sales_tax,2); $this->sales_tax = $sales_tax; } public function Tip() { //global $post_values; //$last_tip_selected = $post_values->tip > 0 ? $post_values->tip : "" ; $tip_output = "<select id='tip' name='tip'>"; for($tip=0.00; $tip<=11.75; $tip+=0.25){ if( $tip == "2") {$selected = " selected";} else {$selected ="";} $formatted_tip = money_format('%i',$tip); $tip_output .= "<option {$selected} id='selected_tip' value='$formatted_tip'>"."$".$formatted_tip ."</option>".PHP_EOL; } $tip_output .= "</select>"; return $tip_output; } private function grandTotal(){ $grand_total = round($this->sales_tax+$this->subtotal+$this->tip,2); $grand_total_formatted = money_format('%i',$grand_total); $this->grand_total = $grand_total_formatted; } Hi Guys, I have built a contact form recently and with help from you guys I managed to add a file upload facility to it, however I am now stuck on something else. The form validation that I have written is always showing the form as not valid when it should be. I'm not sure if it is related to the javascript I have attached to the fields, I have never combined the two things this way before and I am not sure how to fix it. I would be most appreciative of any help you can give me. Here is my code: <?php // BEGIN SOCKET IMPLEMENTATION require_once($_SERVER['DOCUMENT_ROOT'] . '/socket/globals.php'); //Sets the static pageID if ($_GET['article']) { if ($_GET['revision']) { // If viewing a revision from SOCKET $dblookup = "SELECT articleID, datePosted, articleTitle, permaLink, articleBody, sideBody, parent FROM core_pages_revisions WHERE(revisionID ='".$_GET['revision']."') LIMIT 1"; } else { $dblookup = "SELECT articleID, datePosted, articleTitle, permaLink, articleBody, sideBody, parent FROM core_pages WHERE(articleID ='".$_GET['article']."') OR (permaLink ='".$_GET['article']."'"; if($_GET['parent']) { $dblookup .= " AND parent ='".$_GET['parent']."'"; } $dblookup .= ") LIMIT 1"; } $data = mysql_query($dblookup) or die('Failed to return data: ' . mysql_error()); if (mysql_num_rows($data) == 0) { redirect_to('/404');exit;} /* sorts the data into variables and puts them in an array ready to be called when needed */ while(list($articleID, $datePosted, $articleTitle, $permaLink, $articleBody, $sideBody, $parent) = mysql_fetch_array($data, MYSQL_BOTH)) { $meta_title = html_entity_decode(stripslashes("$articleTitle")); $module_ID = 2; $theH1 = '<h1>' . stripslashes(html_entity_decode($articleTitle)) . '</h1>'; $theParent = $parent; $parentUrl = $_SERVER['HTTP_REFERER']; require_once('' . $serverroot . '/style/standard/head.php'); require_once('' . $serverroot . '/style/standard/head2.php'); require_once('style/standard/header.php'); if(isset($_POST['submit'])) { // form validation if($_POST['first_name'] == 'First Name'||$_POST['last_name'] == 'Last Name'||$_POST['your_company'] == 'Company'||$_POST['your_email'] == 'Email'||$_POST['your_telephone'] = 'Telephone') { $errors = "please ensure all mandatory fields are completed"; } else { /* Deals with file uploading */ if (($_FILES["ttt"]["size"] < 500000)) { if ($_FILES["ttt"]["error"] > 0) { echo "Return Code: " . $_FILES["ttt"]["error"] . "<br />"; } else { move_uploaded_file($_FILES["ttt"]["tmp_name"], "upload/" . $_FILES["ttt"]["name"]); $fileLink = $siteroot. "/upload/" . $_FILES["ttt"]["name"]; } } else { echo "Invalid file"; } $to = str_replace('info', 'sales', $sc_email); $subject = "Quotation request from website"; $body = "From: ".$_POST['first_name']." ".$_POST['last_name']."\n"; if ($_POST['job_title']) { $body .= "(".$_POST['job_title']." at ".$_POST['your_company'].")\n"; } $body .= "E-Mail: ".$_POST['your_email']."\n"; $body .= "Telephone: ".$_POST['your_telephone']."\n"; $body .= "Address:\n ".$_POST['your_address']." ,".$_POST['your_country']."\n\n"; $body .= "Project: ".$_POST['project_details']."\n"; $body .= "Translate to: ".$_POST['lang_target']." from ".$_POST['lang_source']."\n"; $body .= "by: ".$_POST['project_deadline']; $body .= "The text: ".$_POST['text_to_translate']; $body .= "Link to attachment: <a href=".$fileLink."> Link </a>"; } if (!$errors) { echo '<h1> Email Sent! </h1>'; echo '<p>Thank you for your enquiry.</p> <p>If it is required a representative will contact you as soon as possible</p><p><strong>Please note:</strong></p> <p>We endeavour to respond to all requests within ' . $sc_response_time . ' however during busy or holiday periods this may increase. </p>'; mail($to, $subject, $body); } else { echo $errors; } } //Main content starts here /****************************/ /* Page starts here */ /****************************/ //echo '<img class="hidden" src="'.$siteroot.'/Scripts/phpThumb/phpThumb.php?src='.$siteroot.'/Scripts/phpThumb/phpThumb.php?w=100&h=100&zc='.$articleImagePos.'&src='.$articleImage.'" />'; if ($_SESSION['access_lvl'] <= 1) { // if a user with appropriate access levels is logged in, allow them to edit this page // to add } echo stripslashes($articleBody); ?> <form id="quote_form" name="quote_form" enctype="multipart/form-data" method="post" action="<?php $_SERVER['SCRIPT_NAME']?>"> <fieldset> <legend> Your Details </legend> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td class="colOne"> Name </td> <td class="colTwo"><label for="first_name">First Name</label> <input type="text" name="first_name" id="first_name" value="<?php if ($_POST['submit']) { echo $_POST['first_name']; } else { echo 'First Name'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='First Name'}" /></td> <td><label for="last_name">Last Name</label> <input type="text" name="last_name" id="last_name" value="<?php if ($_POST['submit']) { echo $_POST['last_name']; } else { echo 'Last Name'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Last Name'}" /></td> </tr> <tr> <td class="colOne"></td> <td class="colTwo"><label for="job_title">Job Title</label> <input type="text" name="job_title" id="job_title" value="<?php if ($_POST['submit']) { echo $_POST['job_title']; } else { echo 'Job Title'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Job Title'}"/></td> <td><label for="your_company">Company</label> <input type="text" name="your_company" id="your_company" value="<?php if ($_POST['submit']) { echo $_POST['your_company']; } else { echo 'Company'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Company'}"/></td> </tr> <tr> <td class="colOne"> Contact </td> <td class="colTwo"><label for="your_telephone">Telephone</label> <input type="text" name="your_telephone" id="your_telephone" value="<?php if ($_POST['submit']) { echo $_POST['your_telephone']; } else { echo 'Telephone'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Telephone'}" /></td> <td><label for="your_email">Email Address</label> <input type="text" name="your_email" id="your_email" value="<?php if ($_POST['submit']) { echo $_POST['your_email']; } else { echo 'Email'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Email'}"/></td> </tr> <tr> <td class="colOne"> Address </td> <td class="colTwo" valign="top"><label for="your_address">Address</label> <textarea name="your_address" id="your_address" cols="45" rows="5" ><?php echo $_POST['your_address']; ?></textarea></td> <td></td> </tr> <tr> <td class="colOne"> Country </td> <td class="colTwo"><label for="your_country">Country</label> <select name="your_country" id="your_country"> <option value="" <?php if (!$_POST['submit']) { echo 'selected="selected'; } ?>>Select your country</option> <?php $countries = mysql_query("SELECT * FROM custom_countries") or die ("Could not get countries list".mysql_error()); while($option = mysql_fetch_array($countries)) { if ($_POST['your_country'] == $option['country_name']) { $selected = 'selected="selected'; } echo '<option '.$selected.' value="' . $option['country_name'].'">' .$option['country_name'].'</option>'; } ?> </select></td> <td></td> </tr> </table> </fieldset> <fieldset> <legend> Your Quote </legend> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td class="colOne"> Languages </td> <td class="colTwo"><label for="lang_source">Source Language</label> <select name="lang_source" id="lang_source"> <option value="" selected="selected">Translate from</option> <?php $languages = mysql_query("SELECT * FROM custom_languages") or die ("Could not get languages list".mysql_error()); while($option = mysql_fetch_array($languages)) { if ($_POST['lang_source'] == $option['language_name']) { $selected = 'selected="selected'; } echo '<option '.$selected.' value="' . $option['language_name'].'">' .$option['language_name'].'</option>'; } ?> </select> <label for="lang_target[]">Target Language</label></td> <td>(hold CTRL to select multiple languages)<select name="lang_target[]" size="6" multiple="multiple" id="lang_target[]"> <option value="" selected="selected">Translate to</option> <?php $languages = mysql_query("SELECT * FROM custom_languages") or die ("Could not get languages list".mysql_error()); while($option = mysql_fetch_array($languages)) { if ($_POST['lang_target'] == $option['language_name']) { $selected = 'selected="selected'; } echo '<option '.$selected.' value="' . $option['language_name'].'">' .$option['language_name'].'</option>'; } ?> </select></td> </tr> <tr> <td class="colOne"> Project</td> <td class="colTwo"><label for="project_details">Project Details</label> <input type="text" name="project_details" id="project_details" value="<?php if ($_POST['submit']) { echo $_POST['project_details']; } else { echo 'Reference'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Reference'}" /></td> <td><label for="project_deadline">Project Deadline</label> <input type="text" name="project_deadline" id="project_deadline" value="<?php if ($_POST['submit']) { echo $_POST['project_deadline']; } else { echo 'Deadline'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Deadline'}" /></td> </tr> <tr> <td class="colOne"> Text to translate</td> <td colspan="2"><label for="ttt">Text to translate</label> <input type="file" name="ttt" id="ttt" value="" /> </tr> <tr> <td> </td> <td><input class="form_button" type="submit" name="submit" id="submit" value="Submit" /><p class="red size10font"><?php echo $error ?></p></td> </tr> </table> </fieldset> </form> </div> <?php //Main content ends here require_once('style/standard/footer.php'); } } ?> I am working on a PHP/MySQL authorization script. The script seems to work initially, but when I try to Login and post the Form ( echo '<form method="post" action=authorize_1.php">'; echo '<table>'; echo '<tr><td>Userid:</td>'; echo '<td><input type="text" name="userid"></td></tr>'; echo '<tr><td>Password:</td>'; echo '<td><input type="password" name="password"></td></tr>'; echo '<tr><td colspan="2" align="center">'; echo '<input type="submit" value="Log in"></td></tr>'; echo '</table></form>'; ) Internet Explorer returns the error that the page is not found.... but I am using one .php file for the authorization so I am sure the page is found because i can see the Login portion. Any ideas as to what is going wrong? Hi, i have written a form that uses 3 dropdown boxes, one of them being populated from a database. The form code is as follows; Code: [Select] <form id="pointsForm" name="pointsForm" method="post" action="points-engine.php"> <select name="car" id="car"> <?php // result of car name collection $result = mysql_query ($query); //Array stored in $cars while($cars=mysql_fetch_array($result)){ //option values added by looping through array echo "<option value=$cars[id]>$cars[carName]</option>"; } ?> </select> <select name="season" id="season"> <option value="low">Low season</option> <option value="mid">Mid season</option> <option value="high">High season</option> <option value="peak">Peak season</option> </select> <select name="period" id="period"> <option value="day">One day</option> <option value="weekend">Weekend</option> <option value="week">One week</option> </select> <input type="submit" name="Submit" value="Submit" /> </form> which posts to; Code: [Select] <?php $car=$_POST['car']; echo $car; $season=$_POST['season']; echo $season; $period=$_POST['period']; echo $period; ?> The initial form code is working fine, the car field is being populated from the database. My problem is the post value for car isn't working... points-engine.php is echoing $season & $period fine but not $car can anyone tell me why? many thanks Richard I have this code with clears the input box onclick... Code: [Select] <input type="text" name="username" value="Username" onclick="value=''"/> however is there any way to use php to get the value of username, before its posted? that way i can make it so it only clears if the value of username is "username" Hi everyone! So, I have recently become interested in the world of webpage design and HTML coding. Thus far, I have created a few simple HTML webpages, the first of which includes some basic facts and information on the state of NC. Everything has gone rather smoothly for me until this point, but I would now like to incorporate a bit of PHP into my knowledge of web development. First, I would like to include a form on my NC page that once submitted, goes to a new PHP page displaying the inputted data to the screen. On the new page, I am attempting to include files: a header and footer. On my other couple of pages for which I would like to add server side includes. And lastly, if possible, it would be great if I could learn how to add some additional features like sending e-mails or displaying the date. Any advice or tips on how to go about this would be greatly appreciated! Hi There, I have a series of submit buttons that I would like to update records in a table when they are pressed. For example, when clicked, I would like them to run the following statement: update mytable set completed = 1 where colname = $variable I would then like it to refresh the page. Is there a way of doing this? Thanks Matt This topic has been moved to Other Programming Languages. http://www.phpfreaks.com/forums/index.php?topic=322013.0 Hello, When a user clicks a Submit button on my page, I'm using an onClick event to essentially just disable the button and change the message to 'Saving'. However, when I add the onClick code, the form no longer posts using PHP. The button does indeed change but the postback never occurs. Is there something extra I need to add or do? Thank you!! This is my submit button: Code: [Select] <input type="submit" id="submit" value="Save Changes" onclick="this.disabled=true; this.value='Saving'">|<a href="/">Cancel</a> Then I have the normal PHP stuff for postback which isn't firing.... Code: [Select] //IF POSTBACK if ($_SERVER['REQUEST_METHOD'] == 'POST') { //DO STUFF HERE } I have one field which is set up as a Text field in my database. What I'm wanting is if the field is blank in the form to just leave the field alone in the database. I need it to be NULL. OR...is there a way to query a database to recognize a field is blank? I have a php index page that includes a form page with a delete button for that row. When I hit the delete button nothing happens. I am not sure if the variable is not passing or if the index.php page is not processing it correctly. Here is the index page that includes the form page: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Welcome Page Test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body> <?php if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } if (isset($_GET['addjoke'])) { include 'form.html.php'; exit(); } $link = mysqli_connect('localhost', 'root', 'password'); if (!$link) { $output = 'Unable to connect to the database server.'; include 'output.html.php'; exit(); } if (!mysqli_set_charset($link, 'utf8')) { $output = 'Unable to set database connection encoding.'; include 'output.html.php'; exit(); } if (!mysqli_select_db($link, 'database')) { $output = 'Unable to locate the database.' . mysqli_error($link); include 'output.html.php'; exit(); } if (isset($_POST['joketext'])) { $joketext=mysqli_real_escape_string($link,$_POST['joketext']); $sql = "INSERT INTO jokes2 (joketext, jokedate) VALUES ('$joketext', CURDATE() )"; if (!mysqli_query($link,$sql)) { $error = 'Error adding submitted joke: ' . mysqli_error($link); include 'error.html.php'; exit(); } header('Location: .'); exit(); } if (isset ($_GET['deletejoke'])) { $id= mysqli_real_escape_string($link,$_POST['id']); $sql = "DELETE FROM jokes2 WHERE id='$id'"; if(!mysqli_query($link,$sql)) { $error= 'Error deleting actor: ' . mysqli_error($link); include 'error.html.php'; exit(); } header('Location: .'); exit(); } $result = mysqli_query($link, 'SELECT jokes2.id, joketext, name, email FROM jokes2 INNER JOIN author ON authorid = author.id'); if (!$result) { $error = 'Error retrieving data' . mysqli_error($link); include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $jokes[] = array('id'=>$row['id'], 'joketext'=>$row['joketext'], 'name'=>$row['name'], 'email'=>$row['email']); } include 'jokes.html.php'; ?> </body> </html> The $_GET array should be getting the variable id passed when the Delete button is pressed on the form, but nothing is happening when I press the button. Here is the form: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Welcome Page Test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <body> <p> <a href="?addjoke">Add Joke </a> </p> <p> Here are all the jokes: </p> <form action="?deletejoke" method="post"> <?php foreach($jokes as $joke): ?> <p> <?php echo htmlspecialchars($joke['id'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($joke['joketext'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($joke['name'], ENT_QUOTES, 'UTF-8'), htmlspecialchars($joke['email'], ENT_QUOTES, 'UTF-8'); ?> <input type="hidden" name="id" value="<?php echo $joke['id']; ?>" /> <input type="submit" value="Delete"/> </p> </form> <?php endforeach; ?> </p> </body> </html> All of my other variables seem to be passing just fine. Any ideas why this one is a problem? Working on a project for school and I am trying to code a form that feeds into a DB. I have been studying the syntax, reading and doing everything I can to get this to work. A little help, pointers, direction would be greatly appreciated. It may be my database structure so I included a image for anyone to see... and the files. Thanks in advance [attachment deleted by admin] This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=346552.0 |