[SOLVED] Hey, newb needing help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Hey, newb needing help

Post by Getran »

Hey, i'm new to learning PHP, and i decided to make a signup/login system, which is working but i want to know if there is a way to make the text that i echo show inside my main table. I don't know how to do it, sorry if i'm really newbish...

Can someone help me please? will i have to make a function or something for it ?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

im not sure exactly what you mean,

if you want text to appear a table

Code: Select all

print "<td>Your Text Here</td>";
or (as i think you mean)

Code: Select all

$text = "Some Text Here";
print "<td>$text</td>";
// $text must be defined before it is called here
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

ahh, i understand what u mean :D

ima try it, thanks man, and thatnks for the fast reply
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

okthat worked, but is there anyway to make it display multiple lines, like this:

i want it to display this:

Login Succesful!
Welcome, (username)
Would you like to process or logout ?
PROCEED LOGOUT

kinda like that, but i tried just doing

$text = "Login successful";
$text = "Welcome"
....etc

but that didn't work, can u tell me if this is possible ?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

you are doing it all wrong....

ok firstly ill explain how to do what you mention

Code: Select all

$text = "Login Succesful!<br>
Welcome, $_POST[username] 
Would you like to process or logout ? 
PROCEED LOGOUT ";
what you should do is create a statement

Code: Select all

// background on status of this script as follows
// user has been verified as a user and a var called $check = 1 (0 is not logged in)
if ($check === 1)
{
// the user is logged in
print $text;
exit;
}
else
{
// the user has not been verified
print "You are not logged In";
exit;
}
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

Ohhh!! thanks man so much :D i did it like this:

Code: Select all

<?
$maincontent = "";
$maincontent .= "<form action='login.php' method='POST'>";
$maincontent .= "<input type='text' name='user' value='Username'><br>";
$maincontent .= "<input type='text' name='pass' value='Password'><br>";
$maincontent .= "<input type='submit' name='logingo' value='Login'><br>";
$maincontent .= "</form>";
$login = $_POST['logingo'];
if ($login)
{
 $user = $_POST['user'];
 $pass = $_POST['pass'];
 require("db_info.php");
 mysql_connect("$host", "$username", "$password");
 mysql_select_db("$database");
 $loginquery = mysql_query("SELECT * from accounts WHERE username='$user'and password='$pass'") or die("ERROR: Username and password not found or not matched!");
 $worked = mysql_fetch_array($loginquery);

 $username = $worked['username'];
 $password = $worked['password'];

 if ($worked)
 {
 	$content = "<font face=verdana size=1 color=ffffff>
    Login Successful!<br>
    Welcome, " . $username . "</font>";
    $loggedin = "1";
 }
 else if (!$worked)
 {
 	$content = "<font face=verdana size=1 color=ffffff>
	Login failed!
    </font>";
    $loggedin = "0";
 }
 else
 {
 	$loggedin = "0";
 }
}
else
{
	$loggedin = "0";
    $content = "";
}
?>
(btw i know i havn't set cookies yet, i'm just testing atm)

then for the check i have this:

Code: Select all

<?php
if ($loggedin == 0)
{
	echo $maincontent;
}
else if ($loggedin == 1)
{
	echo $content;
}
?>
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

gj
Post Reply