Jump to content

[SOLVED] can't input into mysql ....UPDATE


contra10

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>

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.