0

I have a php script that updates a mysql database. Once its done, I want to redirect back to the details page. I know that this can be done in a header redirect, but I can't get it to add the variable to the address. My code that I have is below.

<?php
include "../config.php";
$_GET["hiveid"] = $HiveID;
$_GET["hivename"] = $HiveName;
$_GET["hiveloca"] = $HiveLoca;
mysql_query("UPDATE hives SET HiveName='$HiveName', LocationID='$HiveLoca' WHERE    HiveID='$HiveID'") or die (mysql_error()); 
$URL = "../hivedetails.php?HiveID=" . $HiveID;
header("Location: " . $URL);
?>
4
  • Which variable you want to add? $_GET? Commented Nov 13, 2012 at 3:13
  • 1
    Your variable assignment seems to be the wrong way around. Shouldn't it be $HiveID = $_GET["hiveid"]; ? Commented Nov 13, 2012 at 3:13
  • dont you want $HiveID=$_GET["hiveid"]; ? not that there's any point simply creating new variables. Commented Nov 13, 2012 at 3:13
  • yep...This is what you have to do.. $HiveID=$_GET["hiveid"]; Commented Nov 13, 2012 at 3:18

1 Answer 1

3
  1. STOP WORKING ON THIS CODE and read up about SQL injection vulnerabilities. Your code is just begging for your server to get pwn3d
  2. Learn basic PHP syntax. You're assigning your variables backwards. $HiveID = $_GET['hiveid'] is what you want, and similarly for the other two lines
  3. Your actual problem will go away once you fix #2.
Sign up to request clarification or add additional context in comments.

1 Comment

I have not thought about the SQL injections and I will be definitely be reading up on this more. I have switched around all of my codes and I also realized that I made a huge (newbie) mistake. I used POST in my form, not GET. Thanks again for your help and advise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.