Jump to content

[SOLVED] help on displayng messages based on click


contra10

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

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