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

Link to comment
Share on other sites

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