Jump to content

Problem with form submits


XRS

Recommended Posts

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 by XRS
Link to comment
Share on other sites

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 :D

 

Thanks.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.