We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,459 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to update myphp database using php forms

Hi I have a problem, I have created a site that allows for a user to bid on property but cant get a code to work where it updates a current record in the database

<form id="MakeBid" action="MakeBid.php" method="get">
<div>Bid Now <input type="text" name="pricesoldfor"/></div> 
<input type="submit" value="Place Bid" /> 
</form>

This is my form that im trying to use that will update the databse, each record has a primary key set as propertyID, any help would be appreciated

Thanks

4
Contributors
5
Replies
4 Hours
Discussion Span
1 Year Ago
Last Updated
6
Views
sibbs06
Newbie Poster
7 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Well let me look into my crystal ball too see your coding problem. If you have a problem, please post your code that you are having problems with. From this point i can tell you is to change method from get to post

fobos
Posting Whiz
345 posts since Feb 2009
Reputation Points: 29
Solved Threads: 67
Skill Endorsements: 3
<?php
    if (!isset($_REQUEST['pricesoldfor']) && ($_REQUEST['propertyID']))
    {die("<p>You have to complete all records before pressing add record.</p>\n");
    }

    $pricesoldfor=$_REQUEST['pricesoldfor'];
    $propertyID=$_REQUEST['propertyID'];


    if ($pricesoldfor!=""){
        include 'dbconnect.php';
    $sql="UPDATE property SET pricesoldfor WHERE propertyID = "$propertyID"";    


        mysql_query($sql) or die (mysql_error());
        mysql_close($connection);
        echo "bid of $pricesoldfor has been accepted";
    }
    else {
        die("<p> You have not entered all of the required fields </p>\n");
    }
?>

Sorry about that, this is the code i have so far but i cant see where i have went wrong, i have changed the form to look like this

<form id="MakeBid" action="MakeBid.php" method="post">
<input type="hidden" name="propertyID" value ="propertyID"/>
<div>Bid Now <input type="text" name="pricesoldfor"/></div> 
<input type="submit" value="Update" /> 
</form>
sibbs06
Newbie Poster
7 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Line 7 is wrong, change it to:

$sql = "UPDATE property SET pricesoldfor = $pricesoldfor WHERE propertyID = '$propertyID'";
pritaeas
Posting Prodigy
Moderator
9,533 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98

$sql = "UPDATE property SET pricesoldfor = $pricesoldfor WHERE propertyID = '$propertyID'";

Thanks for the reply, i applied that to my code however I got this error

Parse error: syntax error, unexpected T_VARIABLE in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_v013362/public_html/case/MakeBid.php on line 83

You have any idea what this could be?

Thanks

sibbs06
Newbie Poster
7 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

thats a php compile error, you have some bracket/quote/semicolon missing somewhere. it will be on or before line 83 probably not too far back

Biiim
Posting Pro
504 posts since Oct 2011
Reputation Points: 104
Solved Threads: 83
Skill Endorsements: 7

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0683 seconds using 2.66MB