sailu_mvn Posted March 23, 2007 Share Posted March 23, 2007 Hi i have a value 35 to be passed to the query string in php i tried to first include the value manually in the action tag of form and then add $_REQUEST['pi']. pi is my query string value its not working can anyone help me out Link to comment https://forums.phpfreaks.com/topic/43931-passing-value-to-a-query-string-in-php/ Share on other sites More sharing options...
btherl Posted March 23, 2007 Share Posted March 23, 2007 Can you post your script? And your form as well, if it is in a different file to your script. Link to comment https://forums.phpfreaks.com/topic/43931-passing-value-to-a-query-string-in-php/#findComment-213297 Share on other sites More sharing options...
sailu_mvn Posted March 23, 2007 Author Share Posted March 23, 2007 I want to pass a value of 66 to query string register.php -------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>CC</title> </head> <body> <br><form style="height: 319px;" method="post" action=[size=15pt]"action.php?pi=66"[/size] name="form1"> <p>Fist Name <input name="m_fname" maxlength="25" id="fname" type="text"> <br> <br> Last Name <input name="m_lname" maxlength="25" id="lname" type="text"> <br> <br> Company Name <input name="m_company" maxlength="25" id="company" type="text"> <br> <br> Address <input name="m_add1" id="add1" type="text"> <br> <br> City <input name="m_city" maxlength="25" id="city" type="text"> <br> <br> Email <input name="m_email" maxlength="25" id="email" type="text"> <br> Telephone <input name="m_tel" maxlength="25" id="email" type="text"> </p> <p> <label>Gender </label> <label> <input type="radio" name="m_gender" value="M"> Male </label> <input type="radio" name="m_gender" value="F"> Female </p> <p>Tenant <label> <input type="radio" name="is_tenant" value="Y"> Yes </label> <input type="radio" name="is_tenant" value="N"> No</p> <p> <label> <input name="Submit" type="submit" value="Submit"> </label> </p> <p><br> </p> </form> -------------------------------------------------------------------------------------------- action.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>CC</title> </head> <body> <?php $db = pg_connect('host=localhost dbname=ism user=postgres'); $firstname = pg_escape_string($_POST['m_fname']); $surname = pg_escape_string($_POST['m_lname']); $company = pg_escape_string($_POST['m_company']); $add = pg_escape_string($_POST['m_add1']); $city = pg_escape_string($_POST['m_city']); $emailaddress = pg_escape_string($_POST['m_email']); $telephone=pg_escape_string($_POST['m_tel']); $gender = pg_escape_string($_POST['m_gender']); $tenant = pg_escape_string($_POST['is_tenant']); [size=15pt]$pi = $_REQUEST['pi'];[/size] $query = "INSERT INTO members(m_fname, m_lname,m_company,m_add1,m_city,m_email,m_tel,m_gender,is_tenant) VALUES('" . $firstname . "', '" . $surname . "', '" . $company. "','" . $add . "','" . $city . "','" . $emailaddress . "','" . $telephone . "','" . $gender . "','" . $tenant . "')"; $result = pg_query($query); printf ("These values were inserted into the database - %s %s %s %s %s %s", $firstname, $surname, $company, $add, $city, $emailaddress, $telephone,$gender,$tenant); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/43931-passing-value-to-a-query-string-in-php/#findComment-213313 Share on other sites More sharing options...
papaface Posted March 23, 2007 Share Posted March 23, 2007 You should be using $_GET not $_REQUEST Link to comment https://forums.phpfreaks.com/topic/43931-passing-value-to-a-query-string-in-php/#findComment-213317 Share on other sites More sharing options...
sailu_mvn Posted March 23, 2007 Author Share Posted March 23, 2007 still does not work if in java script i have to do that i will do like this action="action.php?pi=66 (same html form) in action.php String pi=request.getParameter("pi"); this will do the needful. I will need something like this in php Link to comment https://forums.phpfreaks.com/topic/43931-passing-value-to-a-query-string-in-php/#findComment-213323 Share on other sites More sharing options...
kenrbnsn Posted March 23, 2007 Share Posted March 23, 2007 Variables in PHP can not contain a period, ".", as such period will be replaced with underscores, "_", so you should be using: <?php $pi = $_GET['action_pi']; ?> Ken Link to comment https://forums.phpfreaks.com/topic/43931-passing-value-to-a-query-string-in-php/#findComment-213406 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.