Jump to content

form data problem


jimfog

Recommended Posts

My page has 2 links that when one of them is clicked a registration form appears.

The links correspond to different type of business.This info must be passed to the registration form and sent to the server with $_POST.

 

The way I do this you can see that here http://hastebin.com/fomibewiqe.scala (along with other code) at line 17.

 

And here is my problem:

So,when I click the submit button the btype value is sent to the server.

But Imagine this for a while:

 

I click the submit button, an input is empty,I get a warning,I fill it and then click the submit button again(second time).

$_GET['Btype'] gets to be udefined.

 

The reason for this being that when I click the submit button second time the URL is this: /form/php,,,,

btype query parameter is absent from the URL and as such it gets to be undefined.

 

WHat can I do?

Link to comment
Share on other sites

 

Similar to this

<?php
$QS_array = ['hairstyle', 'carshop'];
$QS = "";
if (isset($_GET['btype']) && in_array($_GET['btype'], $QS_array)) {

    $QS = "?btype=" . $_GET['btype'];
}
?>

<form id="bizuserform" action="forms.php<?php echo $QS; ?>" method="post">

Take a look again at the code at line 17:http://hastebin.com/fomibewiqe.scala what gets sent to the server must be values like '1'.You must modify your acode according to that before I can test it.

 

I can do it myself but since you started it I want you to complete it please.

It is important that this little detail gets settled before continuing.

Edited by jimfog
Link to comment
Share on other sites

No, that code will work because the only thing it does is propagate the values in the querystring to the next page. It doesn't affect what gets submitted in the post request. You can also just write a loop to go through all of $_GET and build a querystring with all of the same key/value pairs, add that to the form URL, then if the page gets refreshed it will have all of the same values in $_GET that it had the previous time. You can write whatever other code you want to check for those and fill out values in the form.

Link to comment
Share on other sites

I don't know why line 17 makes a difference? From what I understand clicking any of the links goes to the samepage with btype index with value 'hairstyle' or 'carstop', what the script identify the value and add it to end of 'forms.php' as '?btype=hairstyle' or '?btype=carstop', so you have same querystring url as clicking the link, giving the same when submitting the form, where before it submitted to just 'forms.php' only losing the querystring from the links.

Link to comment
Share on other sites

yes....modifying form action value seems to do the job and transfer data from page to page...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...