PHP and mySQL connection string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hemmo001
Forum Newbie
Posts: 1
Joined: Thu Apr 10, 2014 7:53 am

PHP and mySQL connection string

Post by hemmo001 »

Hi Guys I'm in the middle of creating my own website and I'm having trouble with letting users to register I have created the code but when I click on the "submit" button I'm getting a blank white screen

config.php

Code: Select all

<?php 
//Mysql Connect  |   mysql_connect("host= 3306","username","");
//Below example to connect in localhost
$a=mysql_connect("localhost","root","");

//select your database
$b=mysql_select_db("database_name",$a);
?>
and this is the submit_form.php

Code: Select all

<?php
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username=$_POST['username'];
//$confirmusername=$_POST['confirmusername'];
$password=$_POST['password'];
$confirmpassword=$_POST['confirmpassword'];
$email=$_POST['email'];
$confirmemail=$_POST['confirmemail'];

//Database connection
require_once("config.php");

//mysql query to insert value to database
$query=mysql_query("INSERT INTO registration (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email` ,`confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$password', '$confirmpassword', '$email' , '$confirmemail')");



//if value inserted successyully disply success message
if($query)
{
    
    echo 'Registred successfully..!!</div>';
}else
{
//error message
    echo '<unable to registred !!</div>';
}
?>
Hope someone can help me and give me some pointers please

Rich
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP and mySQL connection string

Post by Celauran »

Make sure error reporting is turned on. Check your error logs. Don't use mysql_ functions; look into PDO. SANITIZE YOUR DATA!
Post Reply