- <form action="" method="post">
- <label>Username:</label>
- <input type="text" name="username">
- <input type="submit" name="submit" value="submit">
- </form>
Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators
rave wrote:Hi,
I Hope Someone Can Help Me Please?
I Would Like To Know If How Can I Code This Option
Website>Page That Put Values Like
Username:
Code:
Check box ( are you sure with your code? )
Submit
After Submit The Code I Put Will Be On My Navicat
Website>Page....>Code Added To Database
Anyone Can Help? I Tried The add_dpts.php But It Doesnt Work
observe wrote:rave wrote:Hi,
I Hope Someone Can Help Me Please?
I Would Like To Know If How Can I Code This Option
Website>Page That Put Values Like
Username:
Code:
Check box ( are you sure with your code? )
Submit
After Submit The Code I Put Will Be On My Navicat
Website>Page....>Code Added To Database
Anyone Can Help? I Tried The add_dpts.php But It Doesnt Work
- <form action="" method="post">
- <label>Username:</label>
- <input type="text" name="username">
- <input type="submit" name="submit" value="submit">
- </form>
Than the PHP part comes
- <?PHP
- if(isset($_POST['submit'])){
- $username = $_POST['username'];
- if(!$username){
- die('Username cannot be empty');
- } else {
- $host = 'localhost'; // Database host (Default: localhost)
- $user = 'root'; // Database username (Default: root)
- $pass = ''; // Database Password (Own setup)
- $db = ''; // Database table
- mysql_connect($host,$user,$pass);
- mysql_select_db($db);
- $sql = "SELECT * FROM accounts WHERE username='".$username."'";
- $res = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($res) > 0){
- die('Username already in use!');
- } else {
- $sql = "INSERT INTO accounts (`username`) VALUEs ('".$username."')";
- $res = mysql_query($sql) or die(mysql_error());
- if($res){
- die('Username successfully added to the database');
- }
- }
- }
- ?>
Keep in mind this is not a safe code this is just to show you how the information is safed into the database
Return to PHP / Web Guides, Scripts and tools.
Users browsing this forum: No registered users and 8 guests