sorensens Posted June 29, 2006 Share Posted June 29, 2006 ^.^;; 2nd question of the day. For some reason my $to_id isn't storing in either p_messages or p_messages_sent but everything else is just fine. So, here are the two pages.The Form: [code]<?phpinclude 'cookie.php';include 'adminbar.php';include 'db.php';?><form action="sendpm.php" method="post"> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td>Recipient:</td> <td> <select name="to_id" id="to_id"> <?php $query = "SELECT name, id FROM membership WHERE status='Y' and name like '$a%' ORDER BY name ";$result = mysql_query($query) or die(mysql_error());if (mysql_num_rows($result) !=0){ while($row = mysql_fetch_array($result)) { extract($row); echo "<option value=\"$id\">$name</option>"; } #while} ?> </select></td> </tr> <tr> <td>Subject: </td> <td><input type="subject" name="subject"></td> </tr> <tr> <td>Message:</td> <td><textarea name="message" rows="15" cols="65"></textarea></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" value="Send PM"></td> </tr> </table> <p> </p></form>[/code]The Script: [code]<?php// sendpm.php// Send PM to users//=================================// put database connection stuff hereinclude 'db.php';// set variable for global_register off$subject = mysql_escape_string(trim(strip_tags($_POST['subject'])));$message = nl2br(mysql_escape_string(trim(strip_tags($_POST['message']))));$to_id = strtolower(mysql_escape_string(trim(strip_tags($_POST['to_id']))));$member = $_COOKIE['member']; // change to the cookie name u gave for the loginif (empty($subject) || empty($message) || empty($to_id)){ die('Error. All fields must be filled in.');} // Now check if recipient is a valid member$qCheck = "select id from membership where lower(name) = '$to_id' limit 1";$rsCheck = mysql_query($qCheck) or die(mysql_error());if (mysql_num_rows($rsCheck) !=0){ die ('Error, recipient is not a member in the system. ');}$row = mysql_fetch_row($rsCheck);$id = $row[0]; // set the id value returned by the query to $id// Obtain the sender id from the system$qID = "select id from membership where name='$member' limit 1";$rsID = mysql_query($qID) or die(mysql_error());$drow = mysql_fetch_array($rsID);$sender_id = $drow[0];// Now insert the PM into the database$qNew = "insert into p_messages (id, sender_id, subject, message, to_id, sentdate) VALUES ('','$sender_id','$id','$subject','$message', now())";$rsNew = mysql_query($qNew) or die(mysql_error());if ($rsNew){ $qNew2 = "insert into p_messages_sent (id, sender_id, subject, message, to_id, sentdate) VALUES ('','$sender_id','$id','$subject','$message', now())"; $rsNew2 = mysql_query($qNew2) or die(mysql_error()); echo '<p>Thank you, PM has been sent to recipient.</p>';}else{ echo '<p>Error, Cannot send PM to recipient.</p>';}?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/13172-variable-not-storing/ Share on other sites More sharing options...
yong Posted June 29, 2006 Share Posted June 29, 2006 i only see the underside code i say other question about your write if you write trimness others see your code will feel bettor you say? :)[b]<select name="to_id" id="to_id"> <?php $query = "SELECT name, id FROM membership WHERE status='Y' and name like '$a%' ORDER BY name ";$result = mysql_query($query) or die(mysql_error());if (mysql_num_rows($result) !=0){ while($row = mysql_fetch_array($result)) { extract($row); echo "<option value=\"$id\">$name</option>"; } #while} ?> </select>[/b]because [b]$to_id = strtolower(mysql_escape_string(trim(strip_tags($_POST['to_id']))));[/b] so the [b]$_POST['to_id'][/b] must have value Quote Link to comment https://forums.phpfreaks.com/topic/13172-variable-not-storing/#findComment-50704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.