Jump to content

Insert record not inserting.


yandoos

Recommended Posts

Hello

 

I'm really not sure what going on but I;m trying to insert a record but it's not working. i just get a white screen. Can you see what the problem is and advise me how to fix it please?

 <form action="add_galleries.php" enctype="multipart/form-data" method="post">		
<input name="mem_id" type="hidden">
<input name="userid" type="text">   
<input name="name" type="text">
<input name="email" type="text">
<select name="user_level">
  <option value="0">Regular</option>
  <option value="1">Admin</option>
</select> 
  
<input name="pass" type="password">
          
<input name="submit" type="Submit" value="Add New Gallery"/>
</form>

and the insert query:

<?php 
ini_set('display_errors', 1); 
error_reporting(E_ALL);
include "include/session.php";
require('config.php'); 
require('include/functions.php'); 
  

if (isset($_POST['submit'])) { 


$pass = $_POST['pass'];
$pass1 = md5($pass);


$name = mysqli_real_escape_string(mysqli $link, $_POST['name']);
$email = mysqli_real_escape_string(mysqli $connection, $_POST['email']);
$user_level = mysqil_real_escape_string(mysqli $connection, $_POST['user_level']);
$userid = mysqli_real_escape_string(mysqli $connection, $_POST['userid']);
$pass2 = mysqli_real_escape_string(mysqli $connection, $_POST['pass1']);


echo $name; echo'<br/>';
echo $userid; echo '<br/>';
echo $email; echo'<br/>';
echo $user_level; echo'<br/>';
echo $pass1; echo'<br/>';


$connection = mysqli_connect($dbhost_name, $username, $password, $database);
$sql = mysqli_query($connection,"INSERT INTO plus_signup (name, userid, user_level, password, email) VALUES ('$name', '$userid', '$user_level', '$pass2', '$email'"); 
$result = mysqli_query($connection,$sql) or die (mysql_error());

}
?>

Thank you

Edited by yandoos
Link to comment
Share on other sites

To help with the debugging process, the following lines of code can be added to the top of your script:

error_reporting(E_ALL);
ini_set('display_errors', 1);

When you're escaping the "user_level" variable, you're calling mysqil_real_escape_string() instead of mysqli_real_escape_string(). Here is your code:

$user_level = mysqil_real_escape_string(mysqli $connection, $_POST['user_level']);

In your calls to mysqli_real_escape_string(), you need to remove the "mysqli" references. The following, for example

$email = mysqli_real_escape_string(mysqli $connection, $_POST['email']);

Should be

$email = mysqli_real_escape_string($connection, $_POST['email']);

Also, you're using the $connection object before it's actually defined. The object is defined here, near the bottom of your script:

$connection = mysqli_connect($dbhost_name, $username, $password, $database);
Link to comment
Share on other sites

try changing

$sql = mysqli_query($connection,"INSERT INTO plus_signup (name, userid, user_level, password, email) VALUES ('$name', '$userid', '$user_level', '$pass2', '$email'"); 
$result = mysqli_query($connection,$sql) or die (mysql_error());

to

$sql = "INSERT INTO plus_signup (name, userid, user_level, password, email) VALUES ('$name', '$userid', '$user_level', '$pass2', '$email'"; 
$result = mysqli_query($connection,$sql) or die (mysql_error());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.