katarra Posted November 6, 2009 Share Posted November 6, 2009 Ok, here is my dilemna. Thanks in advance for any help! I have a text field that someone enters a set of coordinates into. I need to take those coordinates and then convert them into a variable ($c) that can then be used to edit a room script. I have a text field for them to enter, and then a separate *submit* button below that will initiate the action to the next script. Here are my two files so far: Input the Coordinates: <td><INPUT TYPE=text NAME=editcoords SIZE=30></td> <td> <p align="center"> <form name="editlevels" method="post" action="powers/levelgen_admin.php"> <input type=hidden value="" name="Coords"> <input type="submit" value="Edit a Level"> </form> </p></td> Where I need the coordinates inserted into: You are editting <?=$c?>.<br><br> <form action=levedit.php method=post> <table border=0><tr> <td> TITLE:<br> <input type=text name=title value="<?=$title?>"> <br><br> CURRENT:<br> <textarea name=descript rows=10 cols=50><?=$descript?></textarea> <br><br> ALTERNATE:<br> <textarea name=alt rows=10 cols=50><?=$alt?></textarea> </td> <td valign=top width=30%> <table width=100% style=text-align:center><tr> <td width=33%> </td> <td width=33%> NORTH:<br> <select name=n> <option value=0>No</option> <option value=1 <? if ($n == 1) echo "selected" ?>>Yes</option> </select><br>Was <?=$n?> </td> <td width=33%> UP:<br> <select name=u> <option value=0>No</option> <option value=1 <? if ($u == 1) echo "selected" ?>>Yes</option> </select><br>Was <?=$u?> </td> </tr></table> <br> <table width=100% style=text-align:center><tr> <td width=50%> WEST:<br> <select name=w> <option value=0>No</option> <option value=1 <? if ($w == 1) echo "selected" ?>>Yes</option> </select><br>Was <?=$w?> </td> <td width=50%> EAST:<br> <select name=e> <option value=0>No</option> <option value=1 <? if ($e == 1) echo "selected" ?>>Yes</option> </select><br>Was <?=$e?> </td> </tr></table> <br> <table width=100% style=text-align:center><tr> <td width=33%> DOWN:<br> <select name=d> <option value=0>No</option> <option value=1 <? if ($d == 1) echo "selected" ?>>Yes</option> </select><br>Was <?=$n?> </td> <td width=33%> SOUTH:<br> <select name=s> <option value=0>No</option> <option value=1 <? if ($s == 1) echo "selected" ?>>Yes</option> </select><br>Was <?=$u?> </td> <td width=33%> </td> </tr></table> </td> </tr> <tr><td colspan=2> <input type=hidden name=p value=<?=$p?>><input type=hidden name=co value=<?=$c?>><input type=hidden name=username value=<?=$username?>><input type=hidden name=password value=<?=$password?>><input type=hidden name=no value=<?=$no?>> <input type=submit value="Edit Level"> <input type=reset value=Reset> </td></tr></table> Link to comment https://forums.phpfreaks.com/topic/180597-pulling-info-from-a-form-to-fill-a-variable-in-another-script/ Share on other sites More sharing options...
kristofferlc Posted November 6, 2009 Share Posted November 6, 2009 <?php $c = $_POST['Coords'] ?> Link to comment https://forums.phpfreaks.com/topic/180597-pulling-info-from-a-form-to-fill-a-variable-in-another-script/#findComment-952837 Share on other sites More sharing options...
Scotty2024 Posted November 6, 2009 Share Posted November 6, 2009 For Input the Coordinates, the <form> tag needs to encompass the entire form. Try this <form name="editlevels" method="post" action="powers/levelgen_admin.php"> <td><INPUT TYPE="text" NAME="editcoords" SIZE="30"></td> <td> <p align="center"> <input type="submit" value="Edit a Level"> </p></td> </form> To pull the info from the above form, use $_POST like this <?PHP $c = $_POST['editcoords']; ?> You are editting <?PHP echo $c; ?>.<br><br> <form action="levedit.php" method="post"> <table border=0> <tr> <td> TITLE:<br /> <input type="text" name="title" value="<?PHP echo $title; ?>"> <br /><br /> CURRENT:<br /> <textarea name="descript" rows="10" cols="50"><?PHP echo $descript; ?></textarea> <br /><br /> ALTERNATE:<br /> <textarea name="alt" rows="10" cols="50"><?PHP echo $alt; ?></textarea> </td> <td valign=top width=30%> <table width="100%" style="text-align:center"> <tr> <td width=33%> </td> <td width=33%> NORTH:<br /> <select name="n"> <option value="0">No</option> <option value="1" <?PHP if ($n == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $n; ?> </td> <td width=33%> UP:<br /> <select name="u"> <option value="0">No</option> <option value="1" <?PHP if ($u == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $u; ?> </td> </tr> </table> <br /> <table width="100%" style="text-align:center"> <tr> <td width="50%"> WEST:<br /> <select name="w"> <option value="0">No</option> <option value="1" <?PHP if ($w == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $w; ?> </td> <td width=50%> EAST:<br /> <select name="e"> <option value="0">No</option> <option value="1" <?PHP if ($e == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $e; ?> </td> </tr> </table> <br /> <table width="100%" style="text-align:center"> <tr> <td width="33%"> DOWN:<br /> <select name="d"> <option value="0">No</option> <option value="1" <?PHP if ($d == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $n; ?> </td> <td width=33%> SOUTH:<br /> <select name="s"> <option value="0">No</option> <option value="1" <?PHP if ($s == 1) { echo "selected"; } ?>>Yes</option> </select><br />Was <?PHP echo $u; ?> </td> <td width=33%> </td> </tr> </table> </td> </tr> <tr> <td colspan="2"> <input type="hidden" name="p" value="<?PHP echo $p; ?>"><input type="hidden" name="co" value="<?PHP echo $c; ?>"><input type="hidden" name="username" value="<?PHP echo $username; ?>"><input type="hidden" name="password" value="<?PHP echo $password; ?>"><input type="hidden" name="no" value="<?PHP echo $no; ?>"><input type="submit" value="Edit Level"> <input type="reset" value="Reset"> </td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/180597-pulling-info-from-a-form-to-fill-a-variable-in-another-script/#findComment-952839 Share on other sites More sharing options...
katarra Posted November 7, 2009 Author Share Posted November 7, 2009 Okay, that worked! But, if the room is already created, it's not pulling up the info. Is there a way to pull in the information from the mysql database if the room already exists? Link to comment https://forums.phpfreaks.com/topic/180597-pulling-info-from-a-form-to-fill-a-variable-in-another-script/#findComment-952907 Share on other sites More sharing options...
Scotty2024 Posted November 7, 2009 Share Posted November 7, 2009 SELECT can get information from your database. Link to comment https://forums.phpfreaks.com/topic/180597-pulling-info-from-a-form-to-fill-a-variable-in-another-script/#findComment-952953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.