MoMN MoMN - 5 months ago 7
HTML Question

Filling form data by using url extension; Why does this not work?

I have been trying to pre-fill the subject input with information generated in another page, but have been having difficulties with it despite reading a lot of resources about it and seeing examples. I have tried a variety of links, including my most recent attempt with

http://www.myurl.com/folder/index.php/contactform?subject=test
, but even that doesn't work. Anybody have any advice? Also, if you want to test it out before answering, the page experiencing the problem is the contact page of this website. I've removed information from below to make it more general. Thanks in advance for any and all of the help.



<form id="contactform" method="post">
<input name="recipient" type="hidden" value="myemail" />
<input name="subject" type="hidden" value="Contacter" />

<p id="contactname">
<label>Name:</label>
<input name="name" type="text" />
</p>
<p id="contactemail">
<label>Email:</label>
<input name="email" type="text" />
</p>
<p id="title">
<label>Subject:</label>
<input name="title" type="text" />
</p>
<p id="contactmessage">
<label>Message:</label>
<textarea name="message"></textarea>
</p>

<p id="submit">
<input type="button" value="Send" />
</p>
<input name="redirect" type="hidden" value="myredirectpage" />
</form>




Answer

Lets say your page URL is some thing like below

http://www.example.net/index.php?var1=Something&var2=10&var3=ok 

You can use $_GET to get the values of var1, var2,and var3 from the above url

In index.php use the below code to fetch url data

echo $_GET['var1'] // Something
echo $_GET['var2'] // 10
echo $_GET['var3'] // ok

Go through this link http://php.net/manual/en/reserved.variables.get.php

Comments