Nicholas Posted March 20, 2010 Share Posted March 20, 2010 im having problems where this script... even knowing the player is already married, someone can still propose to them, how do you stop it? here is the script... <?php include "globals.php"; $_GET['action'] = (isset($_GET['action']) && is_string($_GET['action'])) ? stripslashes(trim($_GET['action'])) : FALSE; switch($_GET['action']) { case 'propose': propose_form(); break; case 'proposesub': propose_submit(); break; default: index(); break; } function index() { global $db,$ir,$c,$h,$userid; if ($ir['married'] != 0) { die("You are already married"); } else { print"<h1><font color=white>Proposal Center</h1> Do you want to propose to someone? <form action='propose.php?action=propose' method='post'> <input type='submit' class='submit' value='Yes.'> </form> <form action='index.php' method='get'> <input type='submit' class='submit' value='No.'> </form>"; } } function propose_form() { global $db,$ir,$c,$h,$userid; if ($ir['married'] != 0) { die("You are already married"); } else { print"<h1><font color=white>Proposal Center</h1> <form action='propose.php?action=proposesub' method='post'> <font color=white>Please enter the user id of the user you want to propose to: <font color=white>User ID: <input type='text' name='propose' /> <font color=white>Message: <input type='text' name='message' /> <input type='submit' value='Propose' /></form>"; } } function propose_submit() { global $db,$ir,$c,$h,$userid; if ($r['married'] != 0) { die("This person is already married. Sorry. Try someone else."); } if ($ir['married'] != 0) { die("You are already married"); } if ($ir['userid'] == $_POST['propose']) { die("You cannot marry yourself"); } if ($_POST['propose'] <= 0) { die("Invalid user, Try someone else."); } else { $ch=$db->query("SELECT * FROM proposals WHERE proPROPOSED=".abs(intval($_POST['propose'])).""); if ($db->num_rows($ch)!=0) { die("This user already has a pending proposal, please try again later <a href=index.php>> Back</a>"); } else { $m=$db->query("SELECT * FROM users WHERE userid=".abs(intval($_POST['propose'])).""); $r=$db->fetch_row($m); $db->query("INSERT INTO proposals VALUES('', '{$ir['userid']}', '".abs(intval($_POST['propose']))."', '".mysql_real_escape_string($_POST['message'])."')"); event_add(abs(intval($_POST['propose'])),"[url='viewuser.php?u=$userid']".staff_name($ir['userid'])." [{$ir['userid']}][/url] proposed to you click [url='decision.php']<u>HERE</u>[/url] to make your mind up.</a> ",$c); print"<h3>Proposal Center</h3> You proposed to ".staff_name($r['userid'])." [{$r['userid']}], please wait for their decision "; } } } $h->endpage(); ?> if ($r['married'] != 0) { die("This person is already married. Sorry. Try someone else."); } this is my problem... ive tried... if ($r['married'] > 0) { die("This person is already married. Sorry. Try someone else."); } if ($r['married'] != 0) { die("This person is already married. Sorry. Try someone else."); } if ($r['married'] >= 0) { die("This person is already married. Sorry. Try someone else."); } if ($r['married'] => 0) { die("This person is already married. Sorry. Try someone else."); } many other ways too. but its not working! AHHH! its annoying! could someone please help me fix it? Quote Link to comment Share on other sites More sharing options...
wrx Posted March 20, 2010 Share Posted March 20, 2010 function propose_submit() { global $db,$ir,$c,$h,$userid; if ($r['married'] != 0) { ...... just looked at this quickly and noticed $r is that defined in your function. what is returned if you echo $r['married'] , probably nothing wrx Quote Link to comment Share on other sites More sharing options...
Nicholas Posted March 20, 2010 Author Share Posted March 20, 2010 do you mean? global $db,$ir,$c,$h,$userid; into global $db,$r,$ir,$c,$h,$userid; if that works, im gonna cry for such a simple thing... Quote Link to comment Share on other sites More sharing options...
Nicholas Posted March 20, 2010 Author Share Posted March 20, 2010 function propose_submit() { global $db,$r,$ir,$c,$h,$userid; if ($r['married'] != 0) { die("This person is already married. Sorry. Try someone else."); } na it didnt work :( cant figure it out lol. probably most simplist thing to fix, but i cant think of it... Quote Link to comment Share on other sites More sharing options...
seanybob Posted March 20, 2010 Share Posted March 20, 2010 Move this if ($r['married'] != 0) { die("This person is already married. Sorry. Try someone else."); } Under this $m=$db->query("SELECT * FROM users WHERE userid=".abs(intval($_POST['propose'])).""); $r=$db->fetch_row($m); Your $r variable was not defined. Quote Link to comment Share on other sites More sharing options...
wrx Posted March 20, 2010 Share Posted March 20, 2010 probably most simplist thing to fix, but i cant think of it... actually my post tells you what you need to look at and an easy way to troubleshoot it with out giving you the answer directly. or just take the easy way out and read seanybobs post as he gave you the answer :) wrx Quote Link to comment Share on other sites More sharing options...
Nicholas Posted March 21, 2010 Author Share Posted March 21, 2010 thanks lol, i knew it would be a simple thing to do... my minds not working fully lately lol. Quote Link to comment 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.