Jump to content

Recommended Posts

Hey - I just started my first PHP project yesterday and I've hit a bit of a stump. With the help of some premade forms I got a start but now I can't figure out how to correct my error. If anyone has time to just look through it and let me know I'd appreciate it! I'm trying to make a place for members on my game to be able to write checks with their SIM dollars and have it automatically upload to a table.

 

Any help would be appreciated! I'm completely lost!

 


LOGIN.PHP routine
------------------
<?php 
session_start(); 

<?php


 $dbh=mysql_connect ("localhost", "arcadias_bank", "<(filled in correctly on real code>") or 
die ('I cannot connect to the database because: ' . mysql_error());
} 
else { 
if ($_POST['_submit_check']) { 
if ($form_errors = validate_form()) { 
show_form($form_errors); 
}  
else { 
process_form(0); 
}  
}  
else { 
show_form(); 
} 
} 

function show_form($errors = '') { 
print '<form name="authForm" method="POST" action="'.$_SERVER['PHP_SELF'].'">'; 
if ($errors) { 
print '<span style="color:red"><ul><li><b>'; 
print implode('</b></li><li><b>',$errors); 
print '</b></li></ul></span>'; 
}  
print 'userto'; 
print '<input type="text" name="userto" value="'; 
print htmlentities($_POST[userID]) . '"> <br />'; 
print 'password';  
print '<input type="password" name="password" value="'; 
print htmlentities($_POST[password]) . '"> <br />'; 

print '<input type="submit" name="login" value="Login" />'; 
print '<input type="hidden" name="_submit_check" value="1"/>'; 
print '</form>'; 
print '<a href="index.php">Click</a> here if you want to leave this form.'; 
} 

function validate_form() { 
$errors = array(); 
$userid=$_POST['Username']; 
$passwd=$_POST['Password']; 
/**************************************************  ************************** 
* Check username and password in database * 
**************************************************  **************************/ 
// ..... connect to data base 

$text = ""; 
$text = $db->get_var("SELECT * FROM authorized_users WHERE userid='$userfrom' AND passwd=sha1('$passwd')") ; 
if ($text == "") { 
$errors[] = 'Enter a valid username and password!'; 
} 
return $errors; 
} 

function process_form($logged_in) { 
if ($logged_in == 0) { 
// Add the username to the session 
$_SESSION['username'] = $_POST['username']; 
} 
print 'You are logged in as: <b>'.$_SESSION['username'].'</b>'.str_repeat(' ', 10).'<a href="logout.php">Logout</a><br />'; 
print '<p>You can continue processing as a logged-in user ............</p>'; 
} 
?> 
LOGOUT.PHP routine:
-------------------
<?php 
session_start(); 

unset($_SESSION['username']); 
print '<p>You are logged out.</p>'; 
?> 

Link to comment
https://forums.phpfreaks.com/topic/50147-solved-whats-my-error/
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.