PHP - How Can I Use Javascript To Redirect After Posting The Form To Itself?
Hi,
Similar TutorialsHello, I am new to some of the rules to PHP as far as what you can POST or SEND via forms in PHP. I am attempting to change the location of a page via the header() function and basically redirect to another page if the weather is inclimate at an outdoor events center. Currently what I have is two different submit buttons that would post the header() redirect based on if the weather is good or bad. Ex. <div style="width:220px; height:50px;"> <form method="POST" action="../../weather.php"> <input type="submit" value="Good Weather" name="weather_good" /> <input type="submit" value="Bad Weather" name="weather_bad" /> </form> </div> Then the processing for the form is this file - <?php if(isset($_POST['weather_good'])){ $myFile = "../myfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = echo "<?php header ('Location:fall_festival/index.php'); ?>"; fwrite($fh, $stringData); fclose($fh); echo "Page Updated"; } else if(isset($_POST['weather_bad'])){ $myFile = "../myfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $link = "header('Location:fall_festival/weather/index.php');" ; $stringData = $link; fwrite($fh, $stringData); fclose($fh); echo "Page Updated"; } ?> The file doesn't return an error when it's processed but it also doesn't update the file header and redirect to the proper page. Thanks for your time and help! 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 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? 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 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 Hi Guys, I need a bit of help. I need to post a value to a second page, but I want the button to have the same name. The page is to show registered users and then allows a user to send a friend request 'to put it in simple terms'. Username submitbutton username submitbutton And then i do the following <?php foreach ($_POST['username') as $user { echo $user; } ?> How could i go about doing this or would I have to use a 'Hidden' Field. This topic has been moved to Other Programming Languages. http://www.phpfreaks.com/forums/index.php?topic=322013.0 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! 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? 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] Hi, I got this form which passes hidden values as well as a select menu. The only thing is, it doesnt seem to post the form data to the script.
Here is the form
echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="listing_title" value="<?php echo $listing_title ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo "<ul class='results'>"; echo '<li>Quantity:</li>'; 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>'; echo' </ul><br>'; echo '<div align="center">'; echo '<br>'; echo '<input type="submit" value="Confirm Purchase"><br>'; echo '</form><br>';And here is the script that the form is posted to <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to submit care guides"); //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']; if (isset($_POST['listing_title'], $_POST['speciesCommon'], $_POST['cost'], $_POST['business'], $_POST['postage_cost'], $_POST['multipostage'], $_POST['quantity'] ) ) { if( $_POST['listing_title'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['speciesCommon'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['business'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['postage_cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['multipostage'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['quantity'] == "" ) { echo "Error: Please go back and try again"; } else { $listing_title = mysqli_real_escape_string($con, $_POST['listing_title']); $speciesCommon = mysqli_real_escape_string($con, $_POST['speciesCommon']); $cost = mysqli_real_escape_string($con, $_POST['cost']); $business = mysqli_real_escape_string($con, $_POST['business']); $postage_cost = mysqli_real_escape_string($con, $_POST['postage_cost']); $multipostage = mysqli_real_escape_string($con, $_POST['multipostage'] ); $quantity = mysqli_real_escape_string($con, $_POST['quantity'] ); if( $multipostage == "per item" ) { $postage_cost = $quantity * $postage_cost; } elseif( $multipostage == "Combined Postage" ) { $postage_cost; } $total = $cost + $postage_costage; // Writes customer_sales information to the MySQL database $sqlCustomerSales = "INSERT INTO customer_sales(username, listing_title, speciesCommon, total, business, postage_cost, multipostage ) VALUES ( '". $username ."', '". $listing_title ."', '". $speciesCommon ."', '". $total ."', '". $business ."', '". $postage_cost ."', '". $multipostage."' )"; $result1 = mysqli_query($con, $sqlCustomerSales); // This writes the transaction to the MySQL database $memo = $listing_title; $datetime = date("Y-m-d H:i:s"); $regCustomerTransaction = "INSERT INTO customer_transactions(username, datetime, cost, postage_cost, memo) VALUES ( '". $username ."', '". $datetime ."', '". $cost ."', '". $postage_cost ."', '". $memo."' )"; // Query the database $result2 = mysqli_query($con, $regCustomerTransaction); } // This writes the user_stats to the MySQL database $total_items_sold = $quantity; $regUserStats = "INSERT INTO user_stats(username, datetime, total, items_listed, bonus_credits, last_credit_purchase, total_care_guides, total_items_sold, total_currently_listed_items, total_items_purchased, total_diary_entries, feedback ) VALUES ( '". $username ."', '". $datetime ."', '". $total ."', '". $quantity ."', '". $subtotal ."', '". $last_credit_purchase ."', '". $total_care_guides ."', '". $total_items_sold ."', '". $total_currently_listed_items ."', '". $total_items_purchased ."', '". $total_diary_entries ."', '". $feedback."' )"; // Query the database $result3 = mysqli_query($con, $regUserStats); } ?> <h1>Payment to <?php echo $username ?></h1><br> <?php echo '<strong>Thank you for confirming you would like to purchase $speciesCommon; </strong>'; echo '<br>'; echo '<strong>Your payment comes to a total of $total; </strong></h2>'; echo '<br>'; echo '<br>'; echo 'Please complete payment using the PayPal button<br>'; echo '<br>'; echo '<br>'; ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <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> <?php } else { echo 'Sorry we were unable to process your listing. Please contact <a href="mailto:helpdesk@aquapetcentre.com?Subject=Listing%20error">helpdesk@aquapetcentre.com'; die(); include('includes/overall/footer.php'); } // Close the connection mysqli_close($con); ?><h1>Payment to <?php echo $username ?></h1><br> works, but I think that is because it is passed in the SESSION. Any other $variable such as those below echo '<strong>Thank you for confirming you would like to purchase $speciesCommon; </strong>'; echo '<br>'; echo '<strong>Your payment comes to a total of $total; </strong></h2>';does not work. Why is the form not posting the values to the database. Just in case it helps, the form gets its values from the database, and the values are displayed in the sales page on which the form is contained. Here is the page containing the form. <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.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>"; echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="listing_title" value="<?php echo $listing_title ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo "<ul class='results'>"; echo '<li>Quantity:</li>'; 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>'; echo' </ul><br>'; echo '<div align="center">'; echo '<br>'; echo '<input type="submit" value="Confirm Purchase"><br>'; echo '</form><br>'; echo '<br><br> </div>'; exit(); } } echo 'Sorry but we could not find any results.'; } include 'includes/overall/footer.php'; ?>Any help is always appreciated. aquaman This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=346552.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 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? Hey guys, Recently I bumped into a little coding problem. I'm trying to submit information to a multi-part form (including an image upload). The receiving server couldn't read my input, figured I had a nill object somewhere (RoR). First I thought the problem was in my curl setopts, but I think they are fine. It looks like the problem is with the data I'm submitting. I read a bit about multi part posting, and every article I read advised to make a postfield array, which curl would interpret and send out correctly. I did and this was my resulting array: $postfield = array ("social[comments]" => "Test", "avatar_file" => "", "friend_avatar_file" => "", "forum_avatar_file" => "", "social[signature]" => "", "forum_signature_file" => "", "save_profile.x" => "25", "save_profile.y" => "9"); That failed. So I tried making it into a URLENCODED string: $postfield = "social%5Bcomments%5D=".stripslashes($_POST['textarea'])."&avatar_file=&friend_avatar_file=&forum_avatar_file=".$file."&social%5Bsignature%5D=&forum_signature_file=&save_profile.x=25&save_profile.y=9"; This finally worked. I was able to submit the info I wanted. I'd like to send a file with it this time though. I'd need to put this into a postfield array to work though. if(!$file = upload( )) { $file = ''; } else { $file = '@'.$file; } function upload( ) { if(isset($_FILES['file']) && !empty($_FILES['file']['name'])) { $uploaddir = "temp"; if(is_uploaded_file($_FILES['file']['tmp_name'])) { move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); $searchfile = $uploaddir.'/'.$_FILES['file']['name']; return $searchfile; } } return false; } So, I got the uploading covered. I need to put generate the postfield array though. I have the feeling the problem is with the brackets [ ] I'm using. I tried urlencoding the keys in the array, but that didn't work either. Does anybody have an idea on how to handle brackets in post (multi-part) data? Thanks in advance! 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. I ve been having trouble processing form data to the same page as the do on facebook comments. Can php scripts do that. Help me guys!! This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=354451.0 |