Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
if statements making different html
Old 08-20-2009, 10:10 PM if statements making different html
Average Talker

Posts: 27
Trades: 0
So what I want to do is when user is logged in(using sessionsstart) then the spot where it used to say Enter username and password will be replaced with welcome name_of_user
The problem is that the code for getting user to enter username and password is in html format like this
<form action="verification.php" method="post">
<table>
<tr>
<th colspan="2"
bgcolor="gray">
<font color="white">
Sign in
</font>
</th>
</tr>
<tr>
<td bgcolor="silver">
Username:
</td>
<td bgcolor="silver">
<input name="username" type="text"/>
</td>
</tr>
<tr>
<td bgcolor="silver">
Password:
</td>
<td bgcolor="silver">
<input name="password" type="password"/>
</td>
</tr>
</table>
<input type="submit" value="Submit"/>
</form>

And checking if user is currently logged in is this

<?php

session_start();

if (!(isset($_SESSION['login']) && $_SESSION['login'] != ''))
{
Show message saying welcome
}
else
{
Show the enter username and password code I posted above
}
?>

So is there any way I can take the form I made and show it into the else block of code so that it actually works, as far as I know I have no idea how to execute html code inside php block
Cinatas is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-20-2009, 10:33 PM Re: if statements making different html
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
You can switch from PHP syntax and HTML syntax:

PHP Code:
<?php
  
  session_start
();
  
  if (!(isset(
$_SESSION['login']) && $_SESSION['login'] != ''))
  {
    
// Show message saying welcome
  
}
  else
  {
    
// Show the enter username and password code I posted above
    
?>
<form action="verification.php" method="post">
<table>
<tr>
<th colspan="2"
bgcolor="gray">
<font color="white">
Sign in
</font>
</th>
</tr>
<tr>
<td bgcolor="silver">
Username:
</td>
<td bgcolor="silver">
<input name="username" type="text"/>
</td>
</tr>
<tr>
<td bgcolor="silver">
Password:
</td>
<td bgcolor="silver">
<input name="password" type="password"/>
</td>
</tr>
</table>
<input type="submit" value="Submit"/>
</form>
<?php
    
  
}
  
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-21-2009, 01:07 AM Re: if statements making different html
Average Talker

Posts: 27
Trades: 0
sweet thanks you very very much I had no idea I can do that.
Thanks a lot
__________________
Those who can: learn. Those who can't: teach.
Cinatas is offline
Reply With Quote
View Public Profile
 
Old 08-25-2009, 11:28 AM Re: if statements making different html
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,615
Location: UK
Trades: 1
I also did not realise this!!!

Sweeet, This will make life soo much better.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 08-25-2009, 11:49 AM Re: if statements making different html
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Breaking directly "into HTML" will even work from a function call. This, for example, is perfectly valid PHP:
PHP Code:
<?php
function hello_world() {?>
<h1>Hello World!</h1>
<?php
}?>
Subsequent calls to hello_world will output the H1 exactly as advertised
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to if statements making different html
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51261 seconds with 12 queries