-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
[code]
<?php
if (!$_SESSION['username'] && !$_POST['login']){ // No session + No Form Login... Display the form...
echo "
<form action=test.php method=post name=loginform>
Username:
<br>
<input type=text name=username size=20 class=field1>
<br>
Password:
<br>
<input type=password name=password size=20 class=field1>
<br><br>
<input type=submit value=login class=button1>
<br><br>
<a href=register.php>Click Here To Register</a>
</form>
";
} else if ($_POST['username']){
//if the form has been submitted... The ifs + elses between this and next comment arnt that important just checking if the login details are correct...
$username = $_POST['username'];
$password = $_POST['password'];
//---
$result = mysql_query("SELECT * FROM sf_users WHERE username='$username'") or die(mysql_error());
$user = mysql_fetch_array( $result );
$num = mysql_num_rows($result);
if ($num > 0){
echo "<font color=\"#FF0000\"><b>Unknown username, please try again</b></font>";
} else {
$dbusername = $user['username'];
$dbpassword = $user['password'];
if ($username == $dbusername && $password == $dbpassword){
session_register("user");
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
//-- Rest Of Info On The User
$_SESSION['member_id'] = $user['member_id'];
$_SESSION['email'] = $user['email'];
$_SESSION['CL'] = $user['CL'];
$_SESSION['banned'] = $user['banned'];
//-- Session Variables End
echo "<font color=\"#FF0000\"><b>Thank you for login in,<br /> You will be redirected to the protected pages in 2 seconds <META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=index.php\"></b></font>";
} else if ($username == $dbusername && $password != $dbpassword){
echo "<font color=\"#FF0000\"><b>Your Password is incorrect</b></font>";
} else {
echo "<font color=\"#FF0000\"><b>Unknown System Error!<br> Please ensure your Cases are correct!</b></font>";
}
};
} elseif ($_SESSION['username']){
//If we have the session... echo the username has logged in
//Display member options...
$uname = $_SESSION['username'];
echo "<font color='#FFFFFF'><b>$uname... You are already logged in.</b></font>";
} else {
//WOOPS somethings gone wrong if i see this...
echo "<font color='#FFFFFF'><b>Unknown System Error.</b></font>";
}
?>
[/code] -
Would you mind re-editing your post to show the php in the colour?
Make the tags lowercases (e.g. (<?php ?>)) -
To be able to list files from my site to show on my other website.
-
Is it possible to like list files of another website?
-
There isn't any other way?
-
How would I do about listing files in a directory?
-
Like to send data from one page to another?
-
Put some whitespace in there.
[code]
<?php
$k = "$arr_coins / 100";
echo formatnumber($k,3);
echo $arr_coins;
?>
[/code] -
You're going to have to contact osCommerce about this. It's 3rd party and not everybody knows it
-
Can you show us some code?
-
Well, if you make a business account on PayPal they will give you things to make for purchasing goods.
-
Well because this really have nothing to do with PHP. You can easily make a script for this using Javascript ot AJAX
-
This isn't PHP related. You'll have to ask Paypal about this.
-
Mine is just like that...
-
Try:
[code]
$query = "INSERT INTO `inventory` (`item_name`, `ownedID`, `uses`, `tack_type`) VALUE ('$item', '$sid', '$row[uses]', '$row[tack_type]')";
$result = mysql_query($query) or die(mysql_error());
[/code] -
Ok, well I have made a login script which goes threw to see if the user is confirmed and checks if it exists, but each time I enter in all the date it will keep echoing they are incorrect.
Here is the code:
[code]
<? include('header.php'); ?>
<?php
//GRAB DATA FROM THE FORM AND DEFINE VALUES
$uname = $_POST[username];
$upass = $_POST[password];
$action= $_POST[action];
$timestamp = date("G:i:s");
//ECHO FORM IF NOTHING IS VALID
if(empty($uname) && empty($upass) && empty($action)){
echo "<table border=0 cellspacing=0 cellpadding=0>";
echo "<form name=".'check'." action=".'login.php'." method=".'post'.">";
echo "<tr><td colspan=2 align=left><h3>Login</h3></a>";
echo "<tr><td>Username:<td><input type=text name=username>";
echo "<tr><td colspan=2>
<input type=hidden name=action value=check>
<input type=submit value=".'Login'.">";
echo "</form>";
echo "</table";
};
if(isset($uname) && empty($upass) && $action == check){
$check = "SELECT * FROM `users` WHERE username ='$uname'";
$resch = mysql_query($check) or die(mysql_error());
$resc1 = mysql_fetch_assoc($resch);
$confi = $resc1[confirm];
$userid = $resc1[id];
//CHECK IF USER ACCOUNT IS CONFIRMED
if($confi == 0){
echo "Your account is not confirmed, please check your email, to resend please <a href=".'resend.php?id=$userid'.">";
}else {
//PRODUCE SECOND FORM FOR PASSWORD
echo "<table border=0 cellspacing=0 cellpadding=0>";
echo "<form name=login action=".'login.php'." method=".'post'.">";
echo "<tr><td colspan=2 align=left><h3>Login</h3>";
echo "<tr><td>Username:<td><input type=text name=username value=".$uname." readonly>";
echo "<tr><td>Password:<td><input type=password name=password>";
echo "<tr><td colspan=2 valign=left>
<input type=hidden name=action value=login>
<input type=submit value=".'Login'.">";
echo "</form>";
echo "</table>";
};
}else
//CHECK IF USERNAME AND PASSWORD ARE VALID THREW FORM
if(empty($uname) || empty($upass)){
echo "You have not supplied a username and/or a password";
die();
};
//ONLY IF USERNAME AND PASSWORD ARE VALID THE FOLLOWING WITH PROCESS
if($uname && $upass && $action == login){
//CHECK IF USERNAME EXISTS
//DO SQL QUERIES ON UNAME AND UPASS
$q1 = "SELECT * FROM `users` WHERE username ='$uname' AND pass ='$upass' LIMIT 1";
$go = mysql_query($q1) or die(mysql_error());
$q2 = mysql_num_rows($go);
$q3 = mysql_fetch_assoc($go);
//IF EXISTS WILL LOG IN
if($q3 > 0){
echo "You have now been logged in. If you experience any difficulties navigating the website you may have not enabled or allowed cookies for this website!";
//SETTING COOKIES FOR A THREE HOUR PERIOD
setcookie(auth,yes,time()+7200);
setcookie(id,$id['id'],time()+7200);
setcookie(username,$id['username'],time()+7200);
//NEXT WE WILL UPDATE LAST LOGIN
$q4 = "UPDATE `users` SET lastlogin =$timestamp WHERE username ='$uname'";
$go2= mysql_query($q4) or die(mysql_error());
}else {
echo "Your login details were incorrect, please try again!";
};
};
?>
<? include('footer.php'); ?>
[/code]
EDIT: Code fixed to log in, but now cookies are not setting.
[code]
Warning: Cannot modify header information - headers already sent by (output started at
/home/neoblob/public_html/cms/header.php:19) in /home/neoblob/public_html/cms/login.php on line 67
Warning: Cannot modify header information - headers already sent by (output started at
/home/neoblob/public_html/cms/header.php:19) in /home/neoblob/public_html/cms/login.php on line 68
Warning: Cannot modify header information - headers already sent by (output started at
/home/neoblob/public_html/cms/header.php:19) in /home/neoblob/public_html/cms/login.php on line 69
[/code] -
[code]
<? include('header.php'); ?>
<?php
$hash = $_GET['hash'];
$conf = $_GET['confirm'];
$exit = $_GET['exit'];
if($hash == $hash && $conf == yes && $exit == 1){
$checkconf = "SELECT * FROM `users` WHERE confkey='$hash'";
$ccres = mysql_query($checkconf);
$cc2 = mysql_fetch_assoc($ccres);
$ifconf = $cc2[confirm];
if($ifconf == 1){
echo "This account has already been confirmed";
}
$checkhash = "SELECT * FROM users WHERE confkey='$hash'";
$checkhashresult = mysql_query($checkhash);
if(mysql_num_rows($checkhashresult) > 0){
$update = "UPDATE users SET confirm = '1' WHERE confkey='$hash'";
$upres = mysql_query($sql);
echo "Your account has been confirmed!<br><br>$hash";
}
}else{
echo "You are in the wrong place!";
}
?>
<? include('footer.php'); ?>
[/code]
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/neoblob/public_html/cms/confirm.php on line 12
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/neoblob/public_html/cms/confirm.php on line 22
The errors happen when the hash, confirm and exit are present. -
Thanks for the tip :P
-
I'm laughing because I didn't notice that. And all codes do not have to be indented. I was working with cPanel and when I hit tab it goes to the next input.
-
couldn't you do
[code]
<?php
$code = $_GET[code];
echo "
<form name=yo action=gocode.php method=post><br>
Code: <input type=text name=code value=$code><br>
<input type=submit value=Go>
";
?>
[/code]
suttin like that you mean?[/code] -
Haha, fixed. I missed a "; on one of the queries.
-
line 139 is ?>, the last line
-
[tt]Parse error: syntax error, unexpected $end in /home/neoblob/public_html/cms/register.php on line 139[/tt]
[code]
<?php include('header.php'); ?>
<?php
$action = $_POST[action];
$act = $_GET[action];
$username = $_POST[username];
$bday1 = $_POST[year];
$bday2 = $_POST[day];
$bday3 = $_POST[month];
$userpass = $_POST[password];
$passconf = $_POST[passconf];
$email = $_POST[email];
$emailconf = $_POST[emailconf];
$userip = $_SERVER[REMOTE_ADDR];
$ref = $_GET[ref];
$ref2 = $_POST[ref2];
$formact = "register.php";
$formeth = post;
if($ref){
$sql = "SELECT id,username FROM users WHERE id=$ref";
$result = mysql_query($sql);
$result2 = mysql_fetch_assoc($result);
$referrer = $result2[username];
$refid = $result2[id];
};
if(!$ref){
$ref = "0";
};
if(!$act){
echo "Hello! Looks like you want to register for NBCMS. Well just hit register below and get started!!<br><br><a href='?action=register'>Register</a>";
};
if($act == register){
echo "
<h3>Register</h3>
<table border=0 cellspacing=0 cellpadding=2>
<form name=register action=".$formact." method=".$formeth.">
<input type=hidden name=action value=doreg>
<tr><td>
Username:<td colspan=3><input type=text name=username>
<tr><td>
Password:<td colspan=3><input type=password name=password>
<tr><td>
Confirm:<td colspan=3><input type=password name=passconf>
<tr><td>
Email:<td colspan=3><input type=text name=email>
<tr><td>
Confirm:<td colspan=3><input type=text name=emailconf>
<tr><td>
Birthday:<td>
<select name=month>
<option value=January>January
<option value=February>February
<option value=March>March
<option value=April>April
<option value=May>May
<option value=June>June
<option value=July>July
<option value=August>August
<option value=September>September
<option value=October>October
<option value=November>November
<option value=December>December
</select><td>
<select name=day>";
?>
<?php
for($i=1; $i<32; $i++){
echo "<option value=$i>$i</option>";
};
?>
<?php
echo "
</select>
<td>
<select name=year>";
?>
<?php
for($i=1900; $i<1993; $i++){
echo "<option value=$i>$i</option>";
};
?>
<?php
echo"
</select>
<tr><td>
Age:<td>
<select name=age>";
?>
<?php
for($i=13; $i<107; $i++){
echo "<option value=$i>$i</option>";
};
?>
<?php
echo "
</select>";
if($ref){
echo "<tr><td>Referrer<td>$referrer<input type=text name=ref2 value=$refid>";
};
echo "
<tr><td colspan=2>
<input type=submit value=Submit> <input type=reset value=Reset>
</form>
</table>";
};
if($action == doreg){
if(!$username || !$email || !$passconf || !$userpass || !$emailconf){
echo "Please fill in all the missing fields";
};
$sqlcun = "SELECT username,email,ip FROM users WHERE username=$username,email=$email,IP=$userip";
$rescun = mysql_query($sqlcun);
$numcun = mysql_num_rows($rescun);
if($userpass != $passconf){
echo "Your passwords did not match";
};
if($email != $emailconf){
echo "Your emails did not match";
};
if($numcun > 0){
echo "The username, email or IP is already in use!";
};
if($username && $email && $passconf && $userpass && $emailconf){
$addus = "INSERT INTO `users` (`username` , `pass` , `email` , `IP` , `age` , `bday_year` , `bday_month` , `bday_day` , `referred` )VALUES ('$username', '$userpass', '$email', '$userip', '$age', '$bday1', '$bday3', '$bday2', '$ref2');
$resus = mysql_query($addus);
};
};
?>
[/code]
cant figure it out :/ -
You can't have a double $.
You could always just replace it with
$post .= $_POST[$post];
or
$post1 = $_POST[$post];
Gender into a database
in PHP Coding Help
Posted
[code]
$sex = $_POST[gender];
if($sex == male){
$gender = male;
}else{
$gender = female;
};
mysql_query("INSERT INTO `users` (`gender`) VALUES ('$gender')");
[/code]