Jump to content

Submit not working.


jamesxg1

Recommended Posts

Hiya!

 

I dont understand this, when I submit the for and I leave the username and password field empty I get the correct error. But when I fill the fields in, I just get a blank screen.

 

<?php session_start();
include 'system/core/template.php';
$template = new template();

if(isset($_SESSION['username']) && isset($_SESSION['id']) && isset($_SESSION['status'])):
header('Location: myaccount.php');
endif;

if(isset($_GET['i'])):
if($_GET['i'] == 1):
$get = 'Your account has been built but is currently suspended until an Admin approves you.';
elseif ($_GET['i'] == 2):
$get = 'Thank you for registering, you may now login and apply for jobs. We hope you enjoy the services we are offering you.';
endif;
endif;

if(isset($_POST['submit']) && isset($_POST['username']) && isset($_POST['password'])):
if(!empty($_POST['username']) && !empty($_POST['password'])):

$username = mysql_real_escape_string(trim(addslashes($_POST['username'])));
$password = mysql_real_escape_string(trim(addslashes(base64_encode(md5(sha1(md5(mhash(MHASH_CRC32, '823ehshfw87sajkahsDD' . $_POST['password'] . '823ehsp2192u'))))))));

$usernamecheck = "SELECT `username` FROM `members` WHERE `username` = '$username' LIMIT 1";
$runucheck = mysql_query($usernamecheck);

if(!$runucheck):
$text = 'Failed to complete your requested action to login, please contact support or try again.';
else:
if(mysql_num_rows($runucheck) != 1):
$text = 'Incorrect Username, please try again.';
else:

$passwordcheck = "SELECT `password` FROM `members` WHERE `username` = '$username' AND `password` = '$password' LIMIT 1";
$runpcheck = mysql_query($passwordcheck);

if(!$runpcheck):
$text = 'Failed to complete your requested action to login, please contact support or try again.';
else:
if(mysql_num_rows($runpcheck) != 1):
$text = 'Incorrect Password, please try again.';
else:

$getdetails = "SELECT * FROM `members` WHERE `username` = '$username' AND `password` = '$password' LIMIT 1";
$rungd = mysql_query($getdetails);

if(!$rungd):
$text = 'Failed to complete your requested action to login, please contact support or try again.';
else:	
while($details = mysql_fetch_assoc($rungd)):
$banned = $details['banned'];
$id = $details['id'];
$username = $details['username'];
$status = $details['status'];
$permission = $details['permission'];
endwhile;

if($banned == 0):
$_SESSION['id'] = $id;
$_SESSION['username'] = $username;
$_SESSION['status'] = $status;
elseif($banned == 1):
$text = 'Your account seems to be suspended, please contact support.';
endif;

if($permission == 1):
$_SESSION['permission'] = 1;
header('Location: admin/index.php');
elseif ($permission == 0):
header('Location: myaccount.php');

endif;
endif;
endif;
endif;
endif;
endif;
else:
$text = 'Username or Password empty!';
endif;
endif;

$parts = array('TITLE' => 'Login', 'CONTAINERTWOTITLE' => '', 'CONTAINERTWOCONTENT' =>  '', 'CONTAINERTHREETITLE' => '', 'CONTAINERTHREECONTENT' => '', 'CONTAINERONETITLE' => 'Login', 'CONTAINERONECONTENT' => '<form id="loginn" name="loginn" action="" method="post">
<center>
<br />
<p><font color="red">' . $text . ' ' . $get . '</font></p>
<p>Username</p>
<p><input type="text" id="username" name="username" /></p>
<p>Password</p>
<p><input type="password" id="password" name="password" /></p>
<p><input type="submit" class="button" id="submit" name="submit" value="Login" /></p>
</center>
</form>');

$template->load($parts);
?>

 

Many thanks

 

James.

Link to comment
https://forums.phpfreaks.com/topic/195232-submit-not-working/
Share on other sites

Before I even attempt to help you with your issue I just have to point out a few things.

 

  • addslashes is no longer required when your using mysql_real_escape_string.
  • Running your passwords through as many hash and encryption algorithms as you can find does not necessarily make them any more secure than using a simple md5 and salt.
  • A lack of consistent indentation makes your code very difficult to read.

Link to comment
https://forums.phpfreaks.com/topic/195232-submit-not-working/#findComment-1026059
Share on other sites

Before I even attempt to help you with your issue I just have to point out a few things.

 

  • addslashes is no longer required when your using mysql_real_escape_string.
  • Running your passwords through as many hash and encryption algorithms as you can find does not necessarily make them any more secure than using a simple md5 and salt.
  • A lack of consistent indentation makes your code very difficult to read.

 

OK, I didn't know that I will change this, I know but I like to play on the safe side LOL! Ah this is a problem I cannot control as my IDE does not indent the code, but I fully agree with you on this.

 

Many thanks

 

James.

Link to comment
https://forums.phpfreaks.com/topic/195232-submit-not-working/#findComment-1026060
Share on other sites

endif;

endif;

endif;

endif;

endif;

endif;

 

Given that you are using the non-standard alternative language constructs that make it more difficult to identify the start and end of code blocks, using proper indentation is more important.

 

It's no wonder you need help with your logic, you cannot read it and no one else can either.

 

Link to comment
https://forums.phpfreaks.com/topic/195232-submit-not-working/#findComment-1026071
Share on other sites

endif;

endif;

endif;

endif;

endif;

endif;

 

Given that you are using the non-standard alternative language constructs that make it more difficult to identify the start and end of code blocks, using proper indentation is more important.

 

It's no wonder you need help with your logic, you cannot read it and no one else can either.

 

Agreed.

Link to comment
https://forums.phpfreaks.com/topic/195232-submit-not-working/#findComment-1026075
Share on other sites

Bumping a thread without providing additional information about the problem is against the forum's rules.

 

What have you done (other than posting it here) to troubleshoot what your code does when you fill in the form fields? Since we don't have access to your server or your database, you are the only one here who can actually troubleshoot what your code is doing.

 

Best guess is that your code is not outputting anything when you fill in the form fields.

Link to comment
https://forums.phpfreaks.com/topic/195232-submit-not-working/#findComment-1026263
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.