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 ?
[SOLVED] Hey, newb needing help
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
im not sure exactly what you mean,
if you want text to appear a table
or (as i think you mean)
if you want text to appear a table
Code: Select all
print "<td>Your Text Here</td>";Code: Select all
$text = "Some Text Here";
print "<td>$text</td>";
// $text must be defined before it is called hereokthat 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 ?
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
you are doing it all wrong....
ok firstly ill explain how to do what you mention
what you should do is create a statement
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 ";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;
}Ohhh!! thanks man so much
i did it like this:
(btw i know i havn't set cookies yet, i'm just testing atm)
then for the check i have 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 = "";
}
?>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