Jump to content

Recommended Posts

I have a php login in place on my web application.  On the page you go to when you login successfully, I want to display the first name (stored in the database) that is associated with that user that is logged in.  Below is the code on the page.  At line 20 I have attempted something but it didn't work:

 

<?

session_start();

if(!session_is_registered(myusername)){

header("location:officerLogin.php");

}

?>

<html>

 

<head>

<meta http-equiv="Content-Language" content="en-us">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Officer's Area</title></head>

 

<body>

 

<table cellpadding="0" cellspacing="0" width="688" height="583" align="center">

  <!--DWLayoutTable-->

<!-- MSTableType="layout" -->

<tr>

<td height="19" colspan="3" valign="top">Welcome, <?php $_SESSION['myusername'] ?> </td>

</tr>

<tr>

  <td height="80" colspan="3" valign="top">

  <p style="margin-top: 0; margin-bottom: 0">

<font face="georgia, bookman old style, palatino linotype, book antiqua, palatino, trebuchet ms, helvetica, garamond, sans-serif, arial, verdana, avante garde, century gothic, comic sans ms, times, times new roman, serif">

<i><font size="4">When a man becomes a fireman his greatest act of

bravery has been accomplished.  What he does after that is all in the

line of work.  ~Edward F. Croker</font></i><br>

 </font></td>

  </tr>

 

<tr>

<td width="479" height="130" valign="top" bordercolor="#000080" style="border-style: double; border-width: 5px; padding: 1px"><p>Evaluations are now available. To complete the evaluation packet,  <a href="http://www.surveymonkey.com/s.aspx?sm=yucw0wu1q3O1I_2b18iRUtug_3d_3d">Click Here</a> The Password is: <strong>ffeval09</strong></p>

      <p>This evaluations will be available until March 20, 2009. Please complete before that date. </p></td>

<td width="2" rowspan="4" valign="top">

<!-- MSCellType="empty" -->

 </td>

<td width="199" rowspan="4" valign="top">

<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">

<!-- MSCellFormattingTableID="1" -->

<tr>

<td bgcolor="#FF0000" colspan="3" height="2">

<img alt="" width="1" height="2" src="../images/MsSpacer.gif"></td>

</tr>

<tr>

<td bgcolor="#FF0000" width="2">

<img alt="" width="2" height="1" src="../images/MsSpacer.gif"></td>

<td valign="top" width="100%">

<!-- MSCellFormattingType="content" -->

<p align="center" style="margin-top: 0; margin-bottom: 0">

<font size="4" color="#FF0000">News and such...</font></p>

<hr>

<p align="center" style="margin-top: 0; margin-bottom: 0">

<font size="4">Don't forget to complete your evaluations by March 20, 2009 </font></p>

<hr>

<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>

<p align="center" style="margin-top: 0; margin-bottom: 0">

<font size="4">We are starting strong with the Relay for Life with several ideas in the planning process. We have set a goal of $3,000 this year and we need as much participation as possible to help us reach that goal. </font></p>

<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>

<hr>

<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>

<p></td>

<td bgcolor="#FF0000" height="100%" width="2">

<img alt="" width="2" height="1" src="../images/MsSpacer.gif"></td>

</tr>

<tr>

<td bgcolor="#FF0000" colspan="3" height="2">

<img alt="" width="1" height="2" src="../images/MsSpacer.gif"></td>

</tr>

</table> </td>

</tr>

<tr>

<td height="22" valign="top" bgcolor="#FFFFFF"> </td>

</tr>

<tr>

<td height="40" bordercolor="#FF0000" bgcolor="#FFFF00" style="border-style: solid; border-width: 1px; padding-top: 1px; padding-bottom: 1px">

<p align="center"><font size="5" color="#800000"><b>Training Info...</b></font></td>

</tr>

<tr>

<td height="224" valign="top" bordercolor="#FF0000" bgcolor="#C0C0C0" style="border-style: solid; border-width: 1px; padding-top: 1px; padding-bottom: 1px">

<blockquote>

<p align="left">Training is progressing. Brian has implemented a new training calendar, and we have had decent turn out each Thursday. All officers are encouraged to attend each training session as this shows leadership and committment to the firefighters. </p>

<p align="left"> </p>

</blockquote> </td>

</tr>

<tr>

<td height="19"> </td>

<td> </td>

<td> </td>

</tr>

<tr>

  <td height="42" colspan="3" align="center" valign="top"><a href="logout.php">Log Out of Officers Area </a></td>

  </tr>

<tr>

  <td height="68"> </td>

  <td> </td>

  <td> </td>

  </tr>

</table>

 

</body>

 

</html>

Link to comment
https://forums.phpfreaks.com/topic/149297-solved-need-a-little-help/
Share on other sites

Thanks the echo worked great.  Now I have one more question.  There is a first name associated with each username stored in the database.  How can I display the name associated with myusername?  I tried to echo the variable, but I don't think it is looking at the database, it is just pulling the username from the login page.

 

Thanks,

I got this below when I inserted the code, did I miss something?  Sorry, I am just beginning to learn this stuff.

 

Welcome,

Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/athens/public_html/Officers Area/officer_index.php on line 20

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/athens/public_html/Officers Area/officer_index.php on line 20

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/athens/public_html/Officers Area/officer_index.php on line 21

ok, i connected to the database, now I get an error related to the mysql_fetch_array($sql); 

 

Welcome,

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/athens/public_html/Officers Area/officer_index.php on line 32

 

Thanks. 

Yeah, I had the table name right.  I know it was just a rough example.  I have to be honest, I have learned more from this forum than all the tutorials I have tried.  Thanks for your help.  Maybe you can help explain what parts of the example need to be changed to be specific to my site.  That would help.  I knew the table thing because I had used that part of the code elsewhere.  The column name I am trying to pull is called firstname. does that help?

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.