Jump to content

HOw to post variables to another form


jjmusicpro

Recommended Posts

i am trying to post the variables that were put into a form, to post to another page, but cant get it to work.

 

ALso, i dont know how to take those posted variables, and enter them into the db.

 

<form id=\"form1\" name=\"form1\" method=\"post\" action=\"2008pumpplayeradd.php\">
If you dont have a team, but want to play, sign up here!<br />
Player Name:
<label>
<input type=\"text\" name=\"player_name\" />
</label>
<br />
Phone Number:
<label>
<input type=\"text\" name=\"phone_number\" />
</label>
<br />
Player Email.
<label>
<input type=\"text\" name=\"player_email\" />
</label>
<br />
<label>
<input type=\"submit\" name=\"Submit\" value=\"Submit\" />
</label>
</form>

 

here is whats on my form i am posting to

 

$db = mysql_connect("localhost", "pump_user","xxxx") or die("Could not connect."); // Connection to DB
$teamname = GET_("team_name");
$teamcaptain = GET_("team_captain");
$teamphone = GET_("team_number");
$teamemail = GET_("team_address");

if(!$db) 
die("no db");
if(!mysql_select_db("2008pump",$db))
die("No database selected."); 
$acc1="insert into id (teamname,teamcaptain,teamphone,teamemail) values ($teamname,$teamcaptain,$teamphone,$teamnail,now())";
$acc2=mysql_query($acc1) or die("Could not select accounts."); // Error if nothing is selected

 

after that is done, i wanted to post them back to another page, but dont knwo how to do that.

Link to comment
https://forums.phpfreaks.com/topic/97919-how-to-post-variables-to-another-form/
Share on other sites

$teamname = GET_("team_name");
$teamcaptain = GET_("team_captain");
$teamphone = GET_("team_number");
$teamemail = GET_("team_address");

 

to

 

$teamname = $_POST['player_name'];
$teamcaptain = $_POST['phone_number'];
$teamphone = $_POST['player_email'];

 

$_GET is only used if you are passing variables via a URL e.g. index.php?act=index

 

To refer to this, you would then use $_GET['act'].

so i posted the data, and it was entered into the db fine, however, i wanted to do a redirect after the info is enter to another page, how do i do that?

 

this is all thats in my page i posted to

 

 

<?php

$teamname = $_POST['team_name'];
$teamcaptain = $_POST['team_captain'];
$teamphone = $_POST['phone_number'];
$teamemail = $_POST['email_address'];

$db = mysql_connect("localhost", "pump_user","xxxxxx") or die("Could not connect."); // Connection to DB
if(!$db) 
die("no db");
if(!mysql_select_db("pump_db",$db))
die("No database selected."); 
$acc1="insert into teams (Team_Name,Captain_Name,Team_Email,Team_Phone,Team_Entered) values 

('$teamname','$teamcaptain','$teamphone','$teamemail',now())";
$acc2=mysql_query($acc1) or die("Could not enter details."); // Error if nothing is selected

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.