Jump to content

Recommended Posts

Hi

 

Basically this is only a portion of my code, however I'm confident with the rest of it, basically no errors are being thrown, like connection errors or anything, and nothing is being saved into the table therefore I don't know where to go next, help appreciated.

 

<?php
if($password == $verifypassword) {


$connection = mysql_connect("localhost", "loginname", "password");
if (!$connection) {
die("There appears to be username and/or password issue, please check your credentials" . mysql_error());
}

$selectdb = mysql_select_db("koicarp_blog", $connection);
if(!$selectdb) {
die("There is a problem connecting to the database" . mysql_error());
}

$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);

$sql = "INSERT INTO adminlogin (username,password) VALUES ('$username', '$password')";   // place holders used to prevent sql injections

if (!mysql_query($sql, $connection)) {
die('Error: ' . mysql_error());
}
echo "your username and password have been added succesfully, please delete this file";
mysql_close($connection);



}
else
{
echo "doesnt match";
exit();
}

?>

Link to comment
https://forums.phpfreaks.com/topic/150322-solved-possible-syntax-error/
Share on other sites

Hi

 

Okay I did some troubleshooting,  the problem is the code below

 

if(ereg('[^A-Za-z0-9]', $username))
$message = "Please user uppercase & lowercase a to z characters";
echo "$message";
exit();

if(ereg('[^A-Za-z0-9]', $password))
$message = "Please user uppercase & lowercase a to z characters";
echo "$message";
exit();	

 

Even if the condition is true or false, the script still exits, any idea's on solving this?

 

 

if(ereg('[^A-Za-z0-9]', $username)) {
   $message = "Please user uppercase & lowercase a to z characters";
   echo "$message";
   exit();
}

if(ereg('[^A-Za-z0-9]', $password)) {
   $message = "Please user uppercase & lowercase a to z characters";
   echo "$message";
   exit();   
}

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.