Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am trying to learn how to create a signup,and am watching a video to do that,but the problem is i followed their steps but my database connection is not working,i tested it to echo the first,last,username and password when signup button is hit,but the case is that it returns me to my signup.php code,please i did help to resolve the issue,am new to php and mysql.

What I have tried:

this my signup.php code


<?php

include 'dbh.php';

$first = $_POST['first'];
$last = $_POST['last'];
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
echo "welcome";
echo $first."
";
echo $last."
";
echo $uid."
";
echo $pwd."
";

this my dbh.php code

<?php

$conn = mysqli_connect("localhost","","logintest");

if(!$conn){
die("Connection failed".mysqli_connect_error());
}
Posted
Updated 8-May-17 1:57am
Comments
Richard MacCutchan 8-May-17 4:02am    
Where is the code that writes the information to the database?
RAMASWAMY EKAMBARAM 8-May-17 6:47am    
Use PHP Data Objects (PDO) - just search the net and you get plenty of links including the following:
"https://en.wikibooks.org/wiki/PHP_Programming/PHP_Data_Objects"
PDO makes it easy to work with other DBs too (Oracle and PostGRESql)

1 solution

write database user name in databse connection query
$conn = mysqli_connect("localhost","root","","logintest");

<?php

include 'dbh.php';

$first = $_POST['first'];
$last = $_POST['last'];
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];

if(isset($_POST['submit']))    
{
  if(mysqli_query($conn,"insert into table_name values('$first','$last','$uid','$pwd')"))
{
  
  echo"data insert";
}
}

?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900