Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

connect to sql

Options
  • 30-03-2013 9:31am
    #1
    Posts: 0 ✭✭


    44787-creating-loginregistration-forms-with-php

    <?php
    if($_GET["regname"] && $_GET["regemail"] && $_GET["regpass1"] && $_GET["regpass2"] )
    {
    if($_GET["regpass1"]==$_GET["regpass2"])
    {
    $servername="localhost";
    $username="root";


    $conn= mysql_connect($servername,$username)or die(mysql_error());
    mysql_select_db("test",$conn);
    $sql="insert into users (name,email,password)values('$_GET[regname]','$_GET[regemail]','$_GET[regpass1]')";
    $result=mysql_query($sql,$conn) or die(mysql_error());
    print "<h1>you have registered sucessfully</h1>";

    print "<a href='index.php'>go to login page</a>";
    }
    else print "passwords doesnt match";
    }
    else print"invaild data";
    ?>


    Hi guys, trying to connect to a data base and having some trouble. Do I simple just put into the above

    $password="password";

    I have tryed this and I get and error message unable to connect.

    thanks


Comments

  • Registered Users Posts: 1,477 ✭✭✭azzeretti


    Cannot say I know php at all but it looks like you're not passing enough information to your connection function. Shouldn't you need more than server name and username? Password too?


  • Registered Users Posts: 7,041 ✭✭✭Seachmall


    [PHP]$conn = mysql_connect($host,$user,$pass);[/PHP]

    Presumably you need a password to connect to the DB, especially as you're connecting as root.


Advertisement