Question

In: Computer Science

How can I get res_ticket using php getstring? var post_data = "res_id=RYSEZ21786" + "&res_ticket=res8azjcfLQTHNU2mVtG" + "&pan="...

How can I get res_ticket using php getstring?

var post_data = "res_id=RYSEZ21786" +

"&res_ticket=res8azjcfLQTHNU2mVtG" +

"&pan=" + encodeURIComponent(document.getElementById('pan').value) +

"&pan_mm=" + encodeURIComponent(document.getElementById('exp_month').value) +

"&pan_yy=" + encodeURIComponent(document.getElementById('exp_year').value) +

"&cardholder=" + encodeURIComponent(document.getElementById('cardholder').value) +

avs_details +

cvd_details +

"&doTransaction=res_add";

Solutions

Expert Solution

HI,

I think you are asking to sendjavascript variable to php script to get the string "res_ticket=res8azjcfLQTHNU2mVtG"

There is two way to do this:

1. You can split the post_data varialb estring in javascript and can set it in html hidden feild from JS function and with you can get that res_ticket at php side by method $GET["res_ticket"]

like below

<script type="text/javascript">
    //pass your post_data variable in this javascript function
    function getstring(post_data) {
        var arr  = str.split("&");
        
        document.getElementById("res_ticket").value = arr[0];
    }
</script>

<form name="myform" action="" method="POST">
    <input type="hidden" name="res_ticket" id="res_ticket" />
</form>

<?php
   $res_ticket = $_POST['res_ticket']; // or by $_GET["res_ticket"]
   
   echo $query;
   
?>

Another way if you can set your javascript post_data variable to php file by above method and can parse string by php explode metthod like below

// string which can be long like your given string saperated by "&"
$post_data = "res_id=RYSEZ21786&res_ticket=res8azjcfLQTHNU2mVtG" ;


// pass delimiter and string to explode function.it will convert array of string
$post_data_arr = explode('&', $post_data);
// view result using var_dump..it will get the "res_ticket" string from array
var_dump($post_data_arr[1]);

Above are two way to sent javascript variable to php script..

Feel free to ask any question if you might have by comment box.

Thanks


Related Solutions

Using PHP and MYSQL and with a simple customer database, how can I create a simple...
Using PHP and MYSQL and with a simple customer database, how can I create a simple log in and registration system for an ecommerce site
How would I structure the following PHP (PDO) code into a table format using only PHP?...
How would I structure the following PHP (PDO) code into a table format using only PHP? //Our SQL statement, which will select a list of tables from the current MySQL database. $sql = "SELECT * FROM jobs"; //Prepare our SQL statement, $statement = $pdo->prepare($sql); //Execute the statement. $statement->execute(); //Fetch the rows from our statement. $tables = $statement->fetchAll(PDO::FETCH_NUM); //Loop through our table names. foreach($tables as $table){ //Print the table name out onto the page. echo $table[0], ' '; echo $table[1], '...
How can I make my php code without using the money format just loop and if...
How can I make my php code without using the money format just loop and if statements print like this: Change for 5 dollars and 20 cents: 0 ten dollar bills 1 five dollar bills 0 one dollar bills 0 quarters 2 dime 0 nickel 0 pennies I am trying to ask the user to enter amount and output their change they entered. $input; $TenBills = 1000; $FiveBills = 500; $OneBills = 100; $Quarters = 25; $Dimes = 10; $Nickels...
How can I get ATP and NADPH from DHAP using glycolysis and PPP?
How can I get ATP and NADPH from DHAP using glycolysis and PPP?
PHP Language I have XAMPP and I don't know how to display my PHP code. For...
PHP Language I have XAMPP and I don't know how to display my PHP code. For instance, when I create a basic HTML webpage I just open the code into a web browser and it shows me a basic web page. When I try to show a PHP calculation it doesn't show. What are the steps in displaying my PHP doc?
"How can I connect to Hadoop Hive using Python? I've tried using PyHive but always get...
"How can I connect to Hadoop Hive using Python? I've tried using PyHive but always get the error: ...could not start SASL... no mechanism available: unable to find a callback: 2"
When using scapy in python how can I get the same result as the snippit bellow?...
When using scapy in python how can I get the same result as the snippit bellow? (which in run in terminal) >>> sr(IP(dst="192.168.8.1")/TCP(dport=[21,22,23])) Received 6 packets, got 3 answers, remaining 0 packets (<Results: UDP:0 TCP:3 ICMP:0 Other:0>, <Unanswered: UDP:0 TCP:0 ICMP:0 Other:0>) >>> ans,unans=_ >>> ans.summary() IP / TCP 192.168.8.14:20 > 192.168.8.1:21 S ==> Ether / IP / TCP 192.168.8.1:21 > 192.168.8.14:20 RA / Padding IP / TCP 192.168.8.14:20 > 192.168.8.1:22 S ==> Ether / IP / TCP 192.168.8.1:22 >...
Using PHP, create a form that uses the method GET. The form should capture a date...
Using PHP, create a form that uses the method GET. The form should capture a date using two numbers        Month (1 - 12) and Day (1 - 31) Make sure the form is filled with the user's input after the form is submitted and processed, and the page is redisplayed. If data is being passed into the page, then the page should display the date entered by the user and the season of the year. For example, if the...
"Please can I get a feedback on this discussion post below" Can I get it in...
"Please can I get a feedback on this discussion post below" Can I get it in 2 hours please .thanks Tesla is a company recently in the news for a conflict of interest between the SEC and the CEO Elon Musk due to an interest to bring the company private by the CEO who shared on Twitter his short term plans. Production issues, a number of layoffs and the increasing demand for the electric vehicles were expressed by the CEO...
How can I make a PHP web app that will record student's names and grades? Req....
How can I make a PHP web app that will record student's names and grades? Req. A new table in our database called students. Table should include 2 columns; student_name and student_grade [0 - 100]. Need 3 PHP called student_list.php, add_student.php, and delete_student.php. The student_list.php code uses HTML and PHP to list all of the students in your student's table; including their student_name and student_grade [number grade] and letter grade. Convert the number grade to a letter grade as follows....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT