Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append variables to url after form submit

I have this Landing Page that I need to pre-populate with form values after it is submitted. Essentially in the end I have to make the url look like this...

http://example.com/r.php?sid=xx&pub=xxxxx&c1=&c2=&c3=&append=1&firstname=Test&lastname=Smith&address=2211+Commerce+St.&city=Dallas&state=TX&zipcode=75080&[email protected]

What I currently have now for the form is...

<form name="regForm" method="get" action="http://example.com/r.php?sid=xx&pub=xxxx&c1=&c2=&c3=&append=1">
    <input id="firstname" class="text" type="text" name="firstname"/><br>
    <input id="lastname" class="text" type="text" name="lastname" /><br>
    <input id="email" class="text" type="text"  name="email" /><br>
    <input id="address" class="text" type="text" /><br>
    <input id="city" class="text" type="text"/><br>
    <input id="zipcode" class="text" type="text" maxlength="5" name="zipcode" /><br>
    <input type="submit" value="Send Me My FREE List" id="submitBtn2"/>
</form>

How do i create that URL above after the form is submitted? I have been racking my brain all day on this and can't figure it out, i feel like im close.

thanks for the help!

like image 553
DEM Avatar asked Feb 20 '23 04:02

DEM


1 Answers

Include the extra parameters as hidden form fields instead of inline query parameters:

<form name="regForm" method="get" action="http://example.com/r.php">
    <input type="hidden" name="sid" value="xx" />
    <input type="hidden" name="pub" value="xxxx" />
    <input type="hidden" name="c1" value="" />
    <input type="hidden" name="c2" value="" />
    <input type="hidden" name="c3" value="" />
    <input type="hidden" name="append" value="1" />

    <input id="firstname" class="text" type="text" name="firstname"/><br>
    <input id="lastname" class="text" type="text" name="lastname" /><br>
    <input id="email" class="text" type="text"  name="email" /><br>
    <input id="address" class="text" type="text" /><br>
    <input id="city" class="text" type="text"/><br>
    <input id="zipcode" class="text" type="text" maxlength="5" name="zipcode" /><br>
    <input type="submit" value="Send Me My FREE List" id="submitBtn2"/>
</form>
like image 162
Ben Lee Avatar answered Feb 22 '23 23:02

Ben Lee