X10 hosting help mysql

Xtendcorp

New Member
Messages
3
Reaction score
0
Points
0
I am making a php/mysql based login system and im trying to find how to conect with a database

in the script it says:

Code:
<?php
  $host="localhost"; // Host name 
  $username=""; // Mysql username 
  $password=""; // Mysql password 
  $db_name="test"; // Database name 
  $tbl_name="members"; // Table name 
                                                       // Connect to server and select databse.
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
                                                       // username and password sent from  form 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 
                                                       // To protect MySQL injection ([URL="http://us.php.net/mysql_real_escape_string"]more detail about MySQL injection[/URL])
                                                        $myusername = stripslashes($myusername);
                                                        $mypassword = stripslashes($mypassword);
                                                        $myusername = mysql_real_escape_string($myusername);
                                                      $mypassword = mysql_real_escape_string($mypassword);
                                                       $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
                                                        $result=mysql_query($sql);
                                                       // Mysql_num_row is counting table row
                                                        $count=mysql_num_rows($result);
                                                        // If result matched  $myusername  and $mypassword,  table row must be 1 row
                                                       if($count==1){
                                                        // Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
                                      header("location:login_success.php");
                                      }
                                      else {
                                      echo "Wrong Username or Password";
                                      }
                                      ?>


So basicaly cut it down to this:

Code:
$host="localhost"; // Host name 
  $username=""; // Mysql username 
  $password=""; // Mysql password 
  $db_name="test"; // Database name 
  $tbl_name="members"; // Table name                                                          // Connect to server and select databse.

the database user,pass and db name is fine but how would i connect tio the db host?

please help me quick!
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
the username is *cpanelusername*_*databaseusername*. Password is your cPanel password. db name is *cpanelname*_*dbname*.
 

Xtendcorp

New Member
Messages
3
Reaction score
0
Points
0
Could i please have a wucim example with random username and password??
i get it but nit the last bit the :

db name is *cpanelname*_*dbname*.
thanks"!
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
You need to create a database in cPanel. So if your cPanel name is hello, and the database name is user, it would become hello_user
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
for php

PHP:
<?php
mysql_connect("localhost", "yourusername", "yourpassword") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
 
Last edited:

Xtendcorp

New Member
Messages
3
Reaction score
0
Points
0
Thanks so much that will really help me ,
I will be asking more porbably later
thanks!
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
haha that was forget* not forgive. either way, i'm here to help when i can, that way people can help me when i have problems.
 
Top