Multiple $_GET from a link parameters

2020-03-26 05:38发布

问题:

I'm sending values to php file using js like that:

validation.php?firstName=test?lastName=test?email=test?contactNumber=test?title=test?description=test

And in validation.php I've created array with these values like that:

$data[0] = $_GET['firstName'];
$data[1] = $_GET['lastName'];
$data[2] = $_GET['email'];
$data[3] = $_GET['contactNumber'];
$data[4] = $_GET['title'];
$data[5] = $_GET['description'];

unfortunately php returns me errors, why?

回答1:

? indicates the start of a query string but key/value pairs within it are separated with & or (less commonly) ;.



回答2:

You need to separate them with the ampersand sign:

validation.php?firstName=test&lastName=test&email=test&contactNumber=test&title=test&description=test


回答3:

Use the & instead of the ? in the url between variables.



回答4:

your URL is wrong. Make it like:

validation.php?firstName=test&lastName=test&email=test&contactNumber=test&title=test&description=test