Jump to content

Recommended Posts

hello i am trying to post data from one php page to another using hidden form elements.  but saddly with no joy.

 

i have already used this technique in other parts of the site but the form i am trying to send the data with is generated by php and it is not working.

 

the variables that i am trying to post are posrted to this page with hidden form elements than used and i now trying to to post them on again for one final time.

 

here is the code i am trying to post the data with

 

$sql = ("SELECT * FROM $table WHERE id = $id");
$result = mysql_query($sql);

$row = mysql_fetch_array($result) or die(mysql_error());
echo "<form action=\"update.php\" method=\"post\">";
echo "Date: <input type=\"text\" name=\"date\" value=\"{$row['date']}\" /><br /><br>";
echo "Title:  <input type=\"text\" name=\"title\" value=\"{$row['title']}\" /><br /><br />";
echo "<input type=\"hidden\" name=\"dropdown2\" value=\"{$db['dropdown2']}\" /><br /><br />";
echo "<input type=\"hidden\" name=\"radio2\" value=\"{$table['radio2']}\" /><br /><br />";
echo "<input type=\"hidden\" name=\"id\" value=\"{$id['id']}\" /><br /><br />";
echo "Article:<br /><textarea cols=\"50\" rows=\"10\" name=\"article\" onkeyup=\"textLimit(this, 500)\">{$row['article']}</textarea><br />";
echo "<input type=\"submit\" />";
echo "</form>";

 

i know they are coming to this page as the data is need to connect to the db and that is working fine.  the id is being passed to the next page as i have echoed this out.  the are received on this page with this code

 

$id = $_POST['id'];
$db = $_POST['dropdown2'];
$table = $_POST['radio2'];

Link to comment
https://forums.phpfreaks.com/topic/129600-solved-posting-data/
Share on other sites

when i try to echo out the results i get an c for the db var and an i for the table var were it gets these from i do not know.

 

here is the code were it is generated from

 

<form action="edit.php" method="POST">
<select name="dropdown2">
<option value="constructiondb">Construction</option>
<option value="electricaldb">Electrical</option>
<option value="technicaldb">Technical</option>
</select>
<br />
<select name="radio2">
<option value="internal">Internal News</option>
<option value="general">General News</option>
</select>
<br />
<input type="submit" />
</form>

Link to comment
https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-671877
Share on other sites

to get it to work in the section of code that has this

value=\"{$db['dropdown2']}\"

i simply changed it to this

value=\"$db\

the only reason i can think that it didnt work was to do with the information i was trying to pass on again was already being passed to this page using hidden form data.  if you can explain to me why this was happening that would be nice because although i have fixed it i do not understand what was causing the problem in the first place.

Link to comment
https://forums.phpfreaks.com/topic/129600-solved-posting-data/#findComment-672662
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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