contra10 Posted January 26, 2009 Share Posted January 26, 2009 There are basically two options yes or no...if yes is clicked then the result is sentence 1 if no then result is sentence 2 and the form should not display after either one is clicked ALLOW THIS To BE PUBLIC? <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['eid'])){ $id = $_GET['eid']; } $idp = mysql_real_escape_string($_POST['idev']); if (isset($_POST['true'])){ mysql_query("UPDATE `events` SET `val` = 'true' WHERE `eid` = '$idp'"); if (isset($_POST['false'])){ mysql_query("UPDATE `events` SET `val` = 'false' WHERE `eid` = '$idp'"); ?> Sentence 2 <?php }else{ ?> Sentence 1 <?php }else{ ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" > <input type="submit" name ="true" value="Yes"> <?php echo "<input type='hidden' name='idev' value='$id'>"?> <input type="submit" name ="false" value="No"> </form> <?php } ?> how can i get rid of title too Link to comment https://forums.phpfreaks.com/topic/142514-solved-help-on-displayng-messages-based-on-click/ Share on other sites More sharing options...
rhodesa Posted January 26, 2009 Share Posted January 26, 2009 this is how i would do it: <?php if(is_numeric($_GET['eid'])){ $id = $_GET['eid']; }else{ die("Invalid ID"); } if($_SERVER['REQUEST_METHOD'] == 'POST'){ mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(isset($_POST['true'])){ mysql_query("UPDATE `events` SET `val` = 'true' WHERE `eid` = '$id'"); print "Sentence 1"; }elseif(isset($_POST['false'])){ mysql_query("UPDATE `events` SET `val` = 'false' WHERE `eid` = '$id'"); print "Sentence 2"; } exit; } ?> ALLOW THIS TO BE PUBLIC? <form action="?eid=<?php echo $id; ?>" method="POST"> <input type="submit" name ="true" value="Yes"> <input type="submit" name ="false" value="No"> </form> Link to comment https://forums.phpfreaks.com/topic/142514-solved-help-on-displayng-messages-based-on-click/#findComment-746805 Share on other sites More sharing options...
contra10 Posted January 26, 2009 Author Share Posted January 26, 2009 Thank you...Ill take note Link to comment https://forums.phpfreaks.com/topic/142514-solved-help-on-displayng-messages-based-on-click/#findComment-746812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.