I input the previous inputted values via php variables into the value section of the input tag, but when I go to modify it and update it to the database, the value still stays the same. Is there anyways to combine the two , so that for instance when a user wants to update their listing they could? Thanks.

Recommended Answers

All 5 Replies

post some code

the value in the db stays the same?
the value on the form doesn't get updated?

need a little more info

echo '<a href="?logout"> Logout? </a>';
header ("Location: enter_passcode.html");
echo 'pass is set';
$set="SELECT title, ad_body, contact, zip_code, price, email FROM ads WHERE password=SHA1('$pass')"; 
echo "GET is set".$pass;

}else{ echo 'Get is not set';}
<form method="post" action="post.php">
<input type="text"  name="title" value="<?php echo $title; ?>" size="30" /><p>

<textarea name="ad" rows="10" cols="40" size="150" >
<?php echo htmlspecialchars($ad_body); ?>

<input type="hidden" name="passcode" value="<?php echo $pass ?>" size=12 />

Zip Code :<input type="password" name="passcode" value="<?php echo $zip_code; ?>" size=12 />
Contact:<input type="text" name="contact" value="Enter a website,email, phone number, or other contact detail customers can use to contact you. " size=120/>
<p>Price:<input type="text" name="price" value="$<?php echo $price; ?> " size=50/>
Email:<input type="text" name="email" value="<?php echo $email; ?>"size=50/>
<input type="submit" name="Submit" />
<input type="hidden" name="submitted"/>



Which is then posted to here:

if(isset($_POST['contact']) && isset($_POST['passcode']) && isset($_POST['email']) && isset($_POST['price']) && isset($_POST['title']) && isset($_POST['ad']))
$w="UPDATE ads SET email='$email', price='$price', title='$title', contact='$contact', ad_body='$ad' WHERE password=SHA1('$pass');";

echo "Success";
}else{echo "Fail";}


Hello vivosmith , your code would be a happy place for anyone (no skills needed) that would like to harm your server. Take a look at https://www.daniweb.com/programming/web-development/tutorials/499320/common-issues-with-mysql-and-php . Secondly your variables luck of meaningful names. There are many more out there but I will jump to your question.

Have you tested (through echo , debug , error_log or what ever) what is the value of $w variable ?

Thanks. This is just a prototype in my XAMPP environment, and I did add mysqli_real_escape_string to the first page, but I will need to add it to the second. The passcode is a unique ID akin to save passwords for games. I plan on cross refferencing the email sent with the passcode to make sure it matches with the email, otherwise you are screwed. Or I could make a seperate password and rename the current password ID. I am still working on it yet.

As for output, when I check, it does change to whatever I edit it as, but it does not get uploaded to the databse. Weird. I will check the DB connection.

Figured it out. I had copied passcode to use as a template for other inputs, but forgot to rename it, and used the zipcode instead. Then in a panic I took out the ' ' from the variables in the SQL query, which resulted in NULL. I was able to get it to finally show on the databse so I am set to go. Might need to change a few things, but at least I have an almost working prototype. :) After I get everything set up I will work on getting security to be a bit tighter :) .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.