Jump to content

Recommended Posts

i cant seem to update a value

 

<?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'];
}

if (isset($_POST['true'])){

mysql_query("UPDATE events SET value = 'true' WHERE eid = '$id'");
}
if (isset($_POST['false'])){

mysql_query("UPDATE events SET value = 'false' WHERE eid = '$id'");
}


?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" 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/142508-solved-cant-input-into-mysql-update/
Share on other sites

I don't see where you're putting the "eid" on the URL, so you're probably not getting it. Are you getting any errors?

 

Try this:

<?php
mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("registration") or die(mysql_error());
$tf = array('Yes' => 'true', 'No' => 'false');
if (!isset($_GET['eid'])) {
  echo "Id not set, can't continue<br>\n";
} else {
$id = $_GET['eid'];
$val = $tf[$_POST['submit']];
$q = "update events set value = '" . $val . "' where eid = '$id'";
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" >
<input type="submit" name ="submit" value="Yes">
<input type="submit" name ="submit" value="No">
</form>

 

Ken

this is what i tried...i get my "query was empty"

 

<?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 value = 'true' WHERE eid = '$idp'");
mysql_query($sql) or die(mysql_error());

   // Create the URL string
   $url = "http://localhost/events/createvisible.php?eid=$id"; 
   
   // Final Echo the meta tag
   echo('<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">');
}
if (isset($_POST['false'])){

mysql_query("UPDATE events SET value = 'false' WHERE eid = '$idp'");
mysql_query($sql) or die(mysql_error());

   // Create the URL string
   $url = "http://localhost/events/createvisible.php?eid=$idp"; 
   
   // Final Echo the meta tag
   echo('<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">');
}


?>

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

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.