PHP--MYSQL problem

Page 1 of 1

1 Replies - 318 Views - Last Post: 19 November 2012 - 10:23 PM Rate Topic: -----

#1 jeromerpg11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-January 11

PHP--MYSQL problem

Posted 19 November 2012 - 10:19 PM

im currently trying to learn php but i cant figure out how to make this program work..
this is what i want.. i would like to create a simple PHP application that will enable the user to add, delete, search and update records in my sql database..im currently having troubles with adding records to my database... so i cant proceed to deleting, searching and updating... Im also trying to make it all work in one file only (if it is possible to do) can anyone help me with this?

this is my code

<html>
<body>

<form action="j.php" method="post">
Username: <input type="text" name="username" />
Password: <input type="text" name="password" />
First: <input type="text" name="first" />
Last: <input type="text" name="last" />
about: <input type="text" name="about" />
<input type="submit" />
</form>

</body>
</html>

<?php

$accounts = mysql_connect("localhost" , "root" , "jeromepogi") or die(mysql_error());

mysql_select_db("accounts", $accounts);

$sql = "INSERT INTO users (Username, Password, First, Last, About) VALUES('$_POST[username]', '$_POST[password]', '$_POST[first]', '$_POST[last]', '$_POST[about]')";

if (!mysql_query($sql, $accounts))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($accounts);

?>

Is This A Good Question/Topic? 0
  • +

Replies To: PHP--MYSQL problem

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10781
  • View blog
  • Posts: 40,157
  • Joined: 27-December 08

Re: PHP--MYSQL problem

Posted 19 November 2012 - 10:23 PM

Do not open duplicate threads. Also, please use code tags: :code:.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1