Jump to content

freemancomputer

Members
  • Posts

    66
  • Joined

  • Last visited

Posts posted by freemancomputer

  1. Lines 1-3 are as follows

     

    1   <?php ini_set ("display_errors", "1");
    2   error_reporting(E_ALL);
    3   ?>
    

     

    removed line 13 so it is now as follows

     

    10  header("location:login.php");
    11  }
    13  ?>
    14  <?php
    15  $rank=$_SESSION['rank'];
    

     

    The errors are the same the last one being at line 14 now

     

    Thank you

  2. I am moving to a different hosting site that is using php 5.2 from one that has 5.3. I am running into an error with my session_start() that worked just fine before. Was wondering if I could get some pointers.

     

    These are the errors that I get

     

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started atindex.php:10) in header.php on line 5

     

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at index.php:10) in header.php on line 5

     

    Notice: Undefined index: login in header.php on line 6

     

    Notice: Undefined index: rank in header.php on line 7

     

    Notice: Undefined variable: loggedinusername in header.php on line 8

     

    Notice: Undefined variable: loggedinuseremail in header.php on line 9

     

    Warning: Cannot modify header information - headers already sent by (output started at index.php:10) in header.php on line 10

     

    Notice: Undefined index: rank in header.php on line 15

     

     

    This is what I have in my header that is included in every page.

    4   <?
    5   session_start();
    6   if(!$_SESSION['login']){
    7   $_SESSION['rank'];
    8   $_SESSION['loggedinusername'] = $loggedinusername;
    9   $_SESSION['loggedinuseremail'] = $loggedinuseremail;
    10  header("location:login.php");
    11  }
    12  ?>
    13
    14  <?php
    15  $rank=$_SESSION['rank'];
    16  $loggedinusername=$_SESSION['loggedinusername'];
    17  $loggedinuseremail=$_SESSION['loggedinuseremail'];
    18  ?>
    

  3. I am working on user validation through email and I am having some problems with it. I can get it to work but it gives me probloms some times.

     

    This is the link that is sent to the users after they sign up

    mydomain/confirm.php?id=".$id."&userkey=".$userkey
    

     

    and this is what i have for the confirm page

     

    <?php
    
    //connection info
    
    	$userquery = mysql_query("SELECT * FROM user");
    	$active=mysql_result($userquery,  "active");
    	$userid=mysql_result($userquery,  "id");
    	$userkey=mysql_result($userquery, "userkey");
    
    
    	if ($active == 1) {
    
    		printf("This account has already been activated");
    		echo "<br />";
    	}
    
    	elseif($userkey != $posteduserkey){
    	printf("We are sorry but the data offered does not match data listed, plese contact system admin.");
    	}
    
    	else{
    	$query="UPDATE user SET active='1' WHERE id='$id'";
    
    	mysql_query($query) or die (mysql_error());  
    
    
    	echo "You have activated your account";
    
    	?>
    	<div align="center"><br /><a href="login.php" class="nav">Back to the log in page</a></div>
    
    	<?php
    	}
    
    ?>
    

    This is the fun part. I checked that the id and userkey are correct in the link, and they are. I then replaced the & in the link with & it works in gmail but not yahoo email address. I'm not sure where else to look.

     

    Thanks in advance

     

  4. I am looking to add a comment area to pages that are created with data that is pulled off of a database. I am looking for something like the forums on this site, but not as complex. I was thinking about attempting to use a text file to hold the comments for each ID number that is in my database and then displaying those comments when the ID number is called. I'm not sure how I would go about making a function that would search if there was a text file for that ID number and if not to create one. I'm not even sure if this is the best way to go about it but I know if I put all the comments into a database it will get rather large rather quickly. Any pointers and good tutorials would be welcome.

     

    Sorry if it sounds as if this post is rambling, I think I need to step away from the computer for a bit.

     

    Thanks

  5. I am attempting to have some links show up on my page only if a user is an admin. The way I have the user data base is user name password and rank. rank is a 1 or 2, 2 for admin. This is what I have right now as a test bed, I think the rank variable is not being passed properly but I'm not sure.

     

    Thanks in advance.

     

    This is what i have for the log in page

    <?php
    //connection stuff
    
    $sql="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);
    
    
    $count=mysql_num_rows($result);
    $rank=mysql_num_rows('rank');
    
    
    if($count==1){
    session_start(); 
    $_SESSION['login'] = "1"; 
    $_SESSION['rank'] = $rank;
    header ("Location:index.php");
    } else { 
    $errorMessage = "Invalid Login"; 
    session_start(); 
    $_SESSION['login'] = '';
    } 
    ?>
    

     

    This is the header that will be on every page to keep the session.

    <?php ini_set ("display_errors", "1");
    error_reporting(E_ALL);
    ?>
    <?php
    session_start();
    if(!$_SESSION['login']){
    $_SESSION['rank'];
    header("location:login.php");
    }
    ?>
    
    <?php
    $rank=$_SESSION['rank'];
    ?>
    

     

    And this is what I have to show the link.

    <?php
    if($rank<=2){
    ?>
    <tr>
    <td><span class="nav"><a href="link">link</a></span><br /></td>
    </tr>
    <?php
    }
    ?>
    

  6. I just added a user log on for a site I am building using PHP.  I used a simple session based system for this. I can log on just fine. What I am looking for is a way to pass on in ht session what rank a user is so some links/pages will only show for the admin or the super user but not the normal user. I rank the users as Admin 1, superuser 2, and user 3.

     

    This is what I have for the session in my header that allows you to be logged in.

    <?
    session_start();
    if(!session_is_registered(myusername)){
    header("location:login.php");
    }
    ?>
    

     

    Here is what I have that starts the session

    
    //Connection stuff
    
    $query="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($query);
    
    $count=mysql_num_rows($result);
    
    if($count==1){
    
    session_register("myusername");
    session_register("mypassword");
    header("location:index.php");
    }
    else {
    echo "Wrong Username or Password";
    }
    
    ob_end_flush();
    ?>
    

  7. I have been working on a way to split my data into 2 columns as a way to make the page shorter and easier to read. I have been able get it to split like this

     

    1 2

    3 4

    5 6

     

    But I would rather it go like this, because it would be easier on the eyes.

     

    1 4

    2 5

    3 6

     

    This is what I have now, I have no idea if I'm even on the right track.

      <?php
    include"scripts/connect.php" ;
    
    mysql_connect('localhost',$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM movies WHERE type LIKE 'tv' ORDER BY title";
    $result=mysql_query($query);
    
    $num=mysql_numrows($result);
    
    mysql_close();
    ?>
    <table width="70%" align="left">
    
    <?php
    $i=0;
    while ($i < $num/2)
    {
    
    $title=mysql_result($result,$i,"title");
    
    ?>
    <tr>
    <td><a class="nav" href=/show.php?title=<?php echo urlencode($title); ?>><?php echo $title; ?></td>
    
    
    
    <?php
    while ($i >= $num/2)
    {
    ?>
    
    <td><a class="nav" href=/show.php?title=<?php echo urlencode($title); ?>><?php echo $title; ?></td>
    </tr>
    
    
    <?php
    }
    $i++;
    
    }
    
    ?>
    </table>
    

     

    This will show only the first half of the titles.

     

    Thanks in advance.

  8. jcbones thanks for the reply. When I added that and go to the page I get the page, header, footer and the such just none of the data that should be there. Going to look at it to see if I can figure it out.

     

    Thanks again

  9. I am trying to get the output for a mysql query to be displayed in colums. I have it where it does this but it goes from left to right. I would rather it go from top to bottem, it would look better this way. I will also need it to brake into sevral pages when there are a certain amout of entrys shown. If you know of a  good how to on that let me know please.  The other problom that I am having is to make the output a link. I was able to do this before I attemped to devide everything but if I add in what I had before it comes back with no data.

     

    Here's what I have now that put shows the data from left to right in 2 colums.

     

     <?php
    include"scripts/connect.php" ;
    
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM movies WHERE type LIKE 'movie' ORDER BY title";
    
    if(mysql_query($query))
    {
    $result=mysql_query($query);
    
    $num=mysql_numrows($result);
    
    }
    
    
    for($i=0; $i<$num; $i++)
    {
    if($i%2==0){
    echo "<tr><td>";
    } 
    else{
    echo "<td>";
    }
    
    print mysql_result($result,$i,"title");
    
    if ($i%2==0){
    echo "</td>";
    }
    else{
    echo "</td>";
    }
    }
    echo "</tr>";
    ?>

     

    Thanks in advance

×
×
  • 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.