Jump to content

update/edit


andy_b_1502

Recommended Posts

Hi all,

 

Trying to get my coding to work, so that users may edit or update there user profiles, whats the best way to go about this.

 

Here's what i have as the form:

 

<form action="view02.php" method="post" enctype="multipart/form-data" class="cursive">
  <table width="316" border="0">
   
		<tr>
		  <td colspan=2><h1>Edit Your details </h1>
		    <p>fill out the form with your details...</p></td>
	    </tr>
            <tr>
              <td> </td>
              <td><p> </p>
                <p>Click update to edit...</p>
<p>  </p></td>
            </tr>
            <tr>
              <td> </td>
              <td><p> </p>
                <p>
                  
                  </p>
                <p>
              <p>  </p></td>
            </tr>
            <tr>
              <td>Website:</td>
              <td><p> </p>
                <p>
                  <input name="website" type="text" id="website" value="optional" />
                  </p>
                <p><a href="view02.php?id=<?PHP echo $row['id']; ?>&website=$website">Update</a></p>
              <p>  </p></td>
            </tr>
            <tr>
              <td>Primary Number:</td>
              <td><p> </p>
                <p>
                  <input name="phone" type="text" id="phone" value="incl. area code" />
                  </p>
                <p><a href="view02.php?id=<?PHP echo $row['id']; ?>&number1="incl. area code">Update</a></p>
              <p>  </p></td>
            </tr>
            <tr>
              <td>Secondary Number:</td>
              <td><p> </p>
                <p>
                  <input name="phone2" type="text" id="phone2" value="optional" />
                  </p>
                <p><a href="view02.php?id=<?PHP echo $row['id']; ?>&number2=1">Update</a></p>
              <p> </p></td>
            </tr>
            <tr>
              <td>Company Description:</td>
              <td><p><em>Write a description of what your company does, the services it offers and any additional information here.</em> </p>
                <p>
                  <textarea rows="10" cols="100" name="premiumuser_description" id="premiumuser_description"></textarea>
                </p>
                <p><a href="view02.php?id=<?PHP echo $row['id']; ?>&description=1">Update</a>  </p></td>
            </tr>
            <tr>
              <td> </td>
            </tr>
<tr></tr>
  </table>
</form>

 

And the coding "view02.php":

 

<?PHP
session_start();

include ('php only scripts/db.php');
$id = (int) $_GET['id'];
$website = (int) $_GET['website'];
$phone = (int) $_GET['number1'];
$phone2 = (int) $_GET['number2'];
$premiumuser_decription = (int) $_GET['description'];
$query = "UPDATE companies 
SET website = '$website', phone = '$phone', phone2 = '$phone2', premiumuser_description = '$premiumuser_decription' 
WHERE id = '$id'";
$result = mysql_query($query ) or die("SELECT Error: ".mysql_error());
header("url=view01.php?id=" . $row['id']);
exit();
?>

 

How do i get it to update properly? Thanks

Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Thanks, ive changed it now to:

 

<?PHP
session_start();

include ('php only scripts/db.php');
$id = $_GET['id'];
$website = $_GET['website'];
$phone = $_GET['number1'];
$phone2 = $_GET['number2'];
$premiumuser_decription = $_GET['description'];
$query = "UPDATE companies 
SET website = '$website', phone = '$phone', phone2 = '$phone2', premiumuser_description = '$premiumuser_decription' 
WHERE id = '$id'";
$result = mysql_query($query ) or die("SELECT Error: ".mysql_error());
header("url=view01.php?id=" . $row['id']);
exit();
?>

 

but something weird happened, i get this error message:

 

The server encountered an unexpected condition which prevented it from fulfilling the request.

The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.

Link to comment
Share on other sites

i was just looking for that? where do i find it?

 

Check the directory in  which the error occurred.

 

Also iv'e noticed that the details (i changed the user's website) has been updated to: $website, so thats also incorrect

 

Come again?  I don't know what you're referring to.

Link to comment
Share on other sites

well $website was in the code i uploaded...

 

i was saying that it's actually uploading $website from this line of code:

 

$website = $_GET['website'];
$query = "UPDATE companies SET website = '$website'

 

My question is, how do i get it to upload what the user inputs into the field, NOT $website and so on for the other fields.

 

Ill look for the error log now, thanks

Link to comment
Share on other sites

You are using POST as the method in your <form> block.  And then using $_GET to retrieve said values in your PHP.

 

Either switch the form method to GET or change your $_GET's to $_POST's.  I recommend the latter.

Link to comment
Share on other sites

Okay,  i changed the forms method to GET but i'm still getting the same error:

 

The server encountered an unexpected condition which prevented it from fulfilling the request.

The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.

 

:wtf:

Link to comment
Share on other sites

Is this error sporadic?  You made it sound like it happened when I told you to remove (int) from your code (which would not generate an Internal Server error).

 

To expedite a fix, I would send that message to your hosting provider and have them look into their logs.

Link to comment
Share on other sites

I'm not sure what's causing this, thats why i was asking to see if you or anybody else knew?

 

I already have done what you said, contacted my host; they said it was a scripting issue and told me to debug it from my side (not that helpful lol)

 

Being as you said about the (int) do you reckon i should change anything add/take away from that area or area's?

Link to comment
Share on other sites

okay so it reads like this:

 

header("Location: view01.php?id=" . $row['id']);
exit(0);;
exit();

 

it's currently NOT giving me the error message, but is logging out, and not going back to the same page... nor it updating the details of that user

Link to comment
Share on other sites

Thanks, i commented out the section:

 

/* header("Location: view01.php?id=" . $row['id']); */
echo $query;
exit(0);;
exit();
?>

 

this is what i'm getting now:

 

UPDATE companies SET website = '$website', phone = '', phone2 = '', premiumuser_description = '' WHERE id = '51'

 

 

Link to comment
Share on other sites

Thanks, i commented out the section:

 

/* header("Location: view01.php?id=" . $row['id']); */
echo $query;
exit(0);;
exit();
?>

 

this is what i'm getting now:

 

UPDATE companies SET website = '$website', phone = '', phone2 = '', premiumuser_description = '' WHERE id = '51'

 

 

 

$website is being printed to the screen in variable form?  Can you post your current code, please?

Link to comment
Share on other sites

<?PHP
session_start();

include ('php only scripts/db.php');
$id = $_GET['id'];
$website = $_GET['website'];
$phone = $_GET['number1'];
$phone2 = $_GET['number2'];
$premiumuser_decription = $_GET['description'];
$query = "UPDATE companies 
SET website = '$website', phone = '$phone', phone2 = '$phone2', premiumuser_description = '$premiumuser_decription' 
WHERE id = '$id'";
$result = mysql_query($query ) or die("SELECT Error: ".mysql_error());
/* header("Location: view01.php?id=" . $row['id']); */
echo $query;
exit(0);;
exit();
?>

Link to comment
Share on other sites

Not sure how you managed to get

 

exit(0);;
exit();

 

from the code I gave you.  Simply put:

 

exit(0);

 

However, that is not the problem.  Can you post your latest form.  And...

 

$website is being printed to the screen in variable form?

 

Meaning, you literally see '$website' on the screen when you echo $query?

Link to comment
Share on other sites

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.