Results 1 to 9 of 9

Thread: [RESOLVED] Help with adding authorized users code with php

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    39

    Resolved [RESOLVED] Help with adding authorized users code with php

    Hi all

    could any one what is wrong with the following code, I tried to create user authorisation to add new user to the database the problem is does not add the username and password to the database, which I created with one table called user and does not say whether or not added I did checked the table only the id incremented with empty (without username and password).
    Thank you,

    PHP Code:
    <?php include "header.php"?>
    <?php 

    $self
    $_server['php_self']; #assigning value 

    $username =$_post['username'];

    $password =$_post['password'];



    if((!
    $username) and (!$_password))
    {


        
    $form="please enter all your details";
        
        
    # writting the form

        
    $form.="<form action=\"$self\" ";

        
    $form.= "method=\"post\"> User Name: ";

        
    $form.="<input =\"text\" name = \"username\" ";

        
    $form.= "value\"username\"><br><br> Password:";

        
    $form.="<input =\"password\" name = \"password\"";

        
    $form.= "value\"password\"><br><br>";

        
    $form.="<input type = \"Submit\" value =\"Submit\">";

        
    $form.="</form>";

        echo(
    $form);
    }

    else
    {
        
    //connect to MySQL
        
    $conn mysql_connect("localhost","root","")

        or die(
    "Could not connecte");

        
    //select the database
        
    $dbmysql_select_db"my_database"$conn)
        
        or die(
    "Could not select database");

        
    //create SQL query
        
    $sql="insert into user (username,password) values ('$username','$password')";            

        
    //excute the query

        
    $rsmysql_query($sql,$conn)
        
        or die(
    "Could not excute query"); 

    if(
    $rs)
    {    
        echo(
    "New user $username added" );
    }

    }

    ?>
    Last edited by penagate; Apr 21st, 2007 at 06:40 AM. Reason: Duplicate threads merged; [php] tags added.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width