Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

I need help!

the mail() function

Moderators: macek, egami, gesf

I need help!

Postby pink1000 » Thu May 31, 2012 11:04 am

Please help me with this code. I can not enter into MySQL and do not know where I'm wrong.

<?php

define('TITLE', 'VIRTUAL MUSEUM');
require ('header.html');
include ('footer1.html');

print '<div id="rightcontent">
<h1>ADD USERS</h1>';
session_start();

if (!isset($_SESSION['user'])){
header('Location:login.php');
exit();
}
else{

if (isset($submit)){

if ($dbc = @mysql_connect ('localhost', 'root', 'pass')) {

if (!@mysql_select_db('room')){
die('<p>Could not select the database because:<b>' . mysql_error() . '</b></p>');
}
} else {
die('<p>Could not connect to MySQL because:<b>' . mysql_error() . '</b></p>');
}


$query = "INSERT INTO admin(user, pass, level,name) VALUES ('$user', '$pass', '$level', '$name')";

if (@mysql_query($query)){
print '<p>User ' . $user. ' added.</p>';
} else {
print "<p>Can not add user because:<b>" . mysql_error() . "</b>. query was $query.</p>";
}

mysql_close();

}
}

?>
pink1000
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu May 31, 2012 10:56 am

Re: I need help!

Postby Nullsig » Thu May 31, 2012 11:05 am

This is like the 4th post today with this problem....

Move this line:
Code: Select all
session_start();


To the very first line of the script.
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI


Return to PHP coding => Mail

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.