Jump to content

Please help edit this code! Assign an html textbox to a php variable.


Me1337

Recommended Posts

Hello,

 

I'm trying to get an html textbox assigned to a php variable so I can put this on my panel.

Can you please revise and edit this code?

 

<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("PenguinWorld", $con);
mysql_query("UPDATE pw_users SET Nickname='nick'
WHERE Username='username'");
mysql_close($con);
?>

<html>

<form name="input" action="changed.php" method="get">
Username:<INPUT TYPE = "Text" VALUE ="username" NAME = "username"><br>
New Nick: <INPUT TYPE = "Text" VALUE ="nick" NAME = "nick"><br>
<input type="submit" value="Submit" />
</form>

Link to comment
Share on other sites

The hard part is

mysql_query("UPDATE pw_users SET Nickname='" . mysql_real_escape_string(???) . "' WHERE Username='" . mysql_real_escape_string(???) . "'");

The rest you can find with some creative Googling.

 

Sorry, I'm not that familiar with PHP, I just started a week ago. I don't understand how that code you pasted would help.

Link to comment
Share on other sites

Me1337, mysql_real_escape_string or MRES is an important part of handling user input as far as security. You ALWAYS want to sanitize (make sure input is what you expect it to be and ONLY what you expect, nothing that might cause problems) user input cause you never know what might be sent.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.