XRS Posted August 1, 2013 Share Posted August 1, 2013 (edited) Hello, I've been having some troubles in form submitting with HTML and PHP dynamic pages. In this case, the link to register at my site is index.php?p=r Inside this link, I have a form where the user fills and then have a button to submit it: <form class="form-horizontal margin-none" id="registerform" method="_GET" autocomplete="on" action="index.php?p=r"> <!-- Widget --> <div class="widget widget-heading-simple widget-body-gray"> <div class="widget-body"> <h4>Personal Details</h4> <!-- Row --> <div class="row-fluid"> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="firstname">First name</label> <div class="controls"><input class="span12" id="firstname" name="firstname" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="lastname">Last name</label> <div class="controls"><input class="span12" id="lastname" name="lastname" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="email">E-mail</label> <div class="controls"><input class="span12" id="email" name="email" type="email" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="username">Username</label> <div class="controls"><input class="span12" id="username" name="username" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="password">Password</label> <div class="controls"><input class="span12" id="password" name="password" type="password" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="confirm_password">Confirm password</label> <div class="controls"><input class="span12" id="confirm_password" name="confirm_password" type="password" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <h4>Billing Details</h4> <!-- Row --> <!-- Alert --> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">x</button> <strong>Why we need your billing details?</strong> We need your billing details because as a seller/buyer, we need to know where to send the cards. So insert that data carefully, otherwhise can happen shipment mistakes. </div> <!-- // Alert END --> <div class="row-fluid"> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="address">Address</label> <div class="controls"><input class="span12" id="address" name="address" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="zipcode">Zip Code</label> <div class="controls"><input class="span12" id="zipcode" name="zipcode" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="city">City</label> <div class="controls"><input class="span12" id="city" name="city" type="text" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="State">State</label> <div class="controls"><input class="span12" id="state" name="state" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="confirm_password">Country</label> <div class="controls"><input class="span12" id="confirm_password" name="confirm_password" type="text" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <!-- Row --> <div class="row-fluid uniformjs"> <!-- Column --> <div class="span4"> <h4 style="margin-bottom: 10px;">Policy & Newsletter</h4> <label class="checkbox" for="agree"> <input type="checkbox" class="checkbox" id="agree" name="agree" /> I agree with <a href="#TOS" data-toggle="modal">Terms of Services</a> </label> <label class="checkbox" for="newsletter"> <input type="checkbox" class="checkbox" id="newsletter" name="newsletter" checked="true"/> Receive Newsletter </label> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <!-- Form actions --> <div class="form-actions" align="right"> <button type="submit" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Register</button> </div> <!-- // Form actions END --> </div> </div> <!-- // Widget END --> </form> <!-- // Form END --> The problems keeps in this part of code: <!-- Form actions --> <div class="form-actions" align="right"> <button type="submit" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Register</button> </div> <!-- // Form actions END --> When I click the Register Button, it redirects me to index.php?username......password....Instead of reloading in the same page (index.php?p=r&username=.... ) I would like too the browser link doesn't show that data ( username, password ). Already tried to change the method to POST but it doesn't work. Can anyone help me please? Edited August 1, 2013 by XRS Quote Link to comment Share on other sites More sharing options...
fastsol Posted August 1, 2013 Share Posted August 1, 2013 You say you tried POST but are you sure you did it right? Cause in your current code you have method="_GET" And it should be method="get" OR method="post" There isn't supposed to be a _ in the method name. Quote Link to comment Share on other sites More sharing options...
XRS Posted August 1, 2013 Author Share Posted August 1, 2013 Hi, yes, I tried post and get the right way. I just pasted the code with that error. Overall I managed to bypass that error. It was a simple button format error that was making it redirect to index page. It's now solved Thanks. Quote Link to comment Share on other sites More sharing options...
kicken Posted August 1, 2013 Share Posted August 1, 2013 To expand on why it did not work with method="get" (which it would have defaulted to when you had the invalid _GET value), it is because any query string that is part of the form's action is stripped and replaced with the contents of the form fields upon submit. They are not merged together as you seemed to expect. Basically, when your form is a GET form, your ACTION cannot contain any query string parameters. Any such parameters you want to have passed need to be converted to hidden inputs: <form method="get" action="index.php"> <input type="hidden" name="p" value="r"> Such a restriction does not apply when using the POST method, since the form data is sent via the body of the request not the URL. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.