Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Posts posted by DeanWhitehouse

  1. How can i ban someones ip, i am assuming that when they sign up i need to collect that data and post it to the database, then how can i ban it(if what i said is right)

    i would like to do the same with there username and email.

  2. FOUND THE PROBLEM

     

    <?php
    if ($_SESSION['is_valid'] == true){
    if ($_SESSION['user_level'] == 2){
    echo "<table class='logged_in'><tr><td>
    Welcome"; echo $_SESSION['username']; 
    echo ",<br><a href=''>User Profile</a><br>
    <a href=''>Settings</a><br>
    <a href='logout.php'>Logout</a>
    </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>";
    }
    if ($_SESSION['user_level'] == 1){
    
    echo "<table class='logged_in'><tr><td>
    Welcome "; echo $_SESSION['username']; 
    echo ",<br><a href='user_profile.php'>User Profile</a><br>
    <a href='user_setting.php'>Settings</a><br>
    <a href='admin_centre.php'>Admin Area</a><br>
    <a href='logout.php'>Logout</a>
    </td></tr><tr><td><font color='white'>Logged In</font></td></tr></table>";
    }
    }
    else
    {
    include_once ('login.php');
    }
    ?>

     

    the include at the bottom, if i change this to an echo it works. any ideas why?

  3. so what do i need to change , i have tried placing the require_once for the file with the session_start(); at the thop of the list of requires and that didn't work.

    also this

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/deanwhitehouse.awardspace.co.uk/test/main_forum.php:5) in /home/www/deanwhitehouse.awardspace.co.uk/test/header.php on line 3

     

    line 5 in main_forum.php is the echo

     

    if(mysql_connect)

    {

    echo "You have successfully connected with these details to '$dbname'. <br>Username - '$dbuser'<br> Password - '$dbpass'<br> Database Host - '$dbhost'<br>";}

    to fix the headers sent problem i moved the require for the header.php to the top and that worked, but i still can't connect to it without being logged, in , its really wierd

  4. can you use something like this

    <?php
    
    // Random Game Design: PHP Website Template
    //  Version 1
    //  Copyright Dean Whitehouse, 2008
    require_once 'install.php';
    
    $config_file = "config.inc.php";
    
    $fw=fopen($config_file,"w+") 
    or die("Unable to open file!");	// Unable to open file
    
    $config_host = "\$dbhost = \"".$dbhost."\";\n";
    $config_user = "\$dbuser = \"".$dbuser."\";\n";
    $config_pass = "\$dbpass = \"".$dbpass."\";\n";
    $config_db = "\$dbname = \"".$dbname."\";";
    
    $config_write = $config_host.$config_user.$config_pass.$config_db;
    
    fwrite($fw, "<?php\n".$config_write."\n?>");
    
    fclose($fw);
    
    ?>
    

    with what you want

  5. ok, i added this code

    if(mysql_connect)
    {
    echo "You have successfully connected with these details to '$dbname'. <br>Username - '$dbuser'<br> Password - '$dbpass'<br> Database Host - '$dbhost'<br>";}

    just under the require_once 'db_connect.php';

    and i get these errors

    You have successfully connected with these details to '********'.

    Username - '********'

    Password - '*******'

    Database Host - '********'

    //stars are not shown to me\\

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/deanwhitehouse.awardspace.co.uk/test/main_forum.php:5) in /home/www/deanwhitehouse.awardspace.co.uk/test/header.php on line 3

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'crazyemochild'@'82.197.131.40' (using password: NO) in /home/www/deanwhitehouse.awardspace.co.uk/test/main_forum.php on line 12

     

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/www/deanwhitehouse.awardspace.co.uk/test/main_forum.php on line 12

    Access denied for user 'crazyemochild'@'82.197.131.40' (using password: NO)

  6. ok, now when i add the db_connect script to the actual page, instead of using require_once 'db_connect'; i added

    require_once 'config.inc.php';
    
    
    // Connect to database
    mysql_connect($dbhost,$dbuser,$dbpass)
    or die('Could not connect: ' . mysql_error());
    
    // Select database
    mysql_select_db($dbname)
    or die('Could not find the database: ' . mysql_error());
    $sql="SELECT * FROM $forum_quest ORDER BY id DESC";
    $result=mysql_query($sql) or die (mysql_error());
    

    which is the db_connect form, and this works

  7. I have written a forum, and i get an error message, but this only displays when i am not logged in.

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'crazyemochild'@'82.197.131.40' (using password: NO) in /home/www/deanwhitehouse.awardspace.co.uk/test/main_forum.php on line 9

     

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/www/deanwhitehouse.awardspace.co.uk/test/main_forum.php on line 9

    Access denied for user 'crazyemochild'@'82.197.131.40' (using password: NO)

     

     

    this is the main_forum.php code

    <?php
    require_once 'db_connect.php';
    require_once 'config_table.inc.php';
    require_once 'header.php';
    require_once 'nav_bar.php';
    require_once 'logged_in.php';
    
    $sql="SELECT * FROM $forum_quest ORDER BY id DESC";
    $result=mysql_query($sql) or die (mysql_error());
    ?>
    
    <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
    <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
    <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
    <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
    <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
    </tr>
    
    <?php
    while($rows=mysql_fetch_array($result)){ // Start looping table row
    ?>
    <tr>
    <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
    <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
    <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
    </tr>
    
    <?php
    // Exit looping and close connection
    }
    mysql_close();
    ?>
    <tr>
    <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td>
    </tr>
    </table>

  8. how would i do that?

    <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form id="form1" name="form1" method="post" action="add_topic.php">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td>
    </tr>
    <tr>
    <td width="14%"><strong>Topic</strong></td>
    <td width="2%">:</td>
    <td width="84%"><input name="topic" type="text" id="topic" size="50" /></td>
    </tr>
    <tr>
    <td valign="top"><strong>Detail</strong></td>
    <td valign="top">:</td>
    <td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td>
    </tr>
    <tr>
    <td><strong>Name</strong></td>
    <td>:</td>
    <td><input name="name" type="text" id="name" size="50" /></td>
    </tr>
    <tr>
    <td><strong>Email</strong></td>
    <td>:</td>
    <td><input name="email" type="text" id="email" size="50" /></td>
    </tr>
    <tr>
    <td> </td>
    <td> </td>
    <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>

    the form that is sent.

    i don't want to show them the time when it is sent

  9. well this is the page where the date is inserted.

    <?php
    require_once 'db_connect.php';
    require_once 'config_table.inc.php';
    
    // get data that sent from form
    $topic=$_POST['topic'];
    $detail=$_POST['detail'];
    $name=$_POST['name'];
    $email=$_POST['email'];
    
    $datetime=date("jS of M Y h:ia e"); //create date time
    
    $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";
    $result=mysql_query($sql);
    
    if($result){
    echo "Successful<BR>";
    echo "<a href=main_forum.php>View your topic</a>";
    }
    else {
    echo "ERROR";
    }
    mysql_close();
    ?>

     

    could i change it to this

    <?php
    require_once 'db_connect.php';
    require_once 'config_table.inc.php';
    
    // get data that sent from form
    $topic=$_POST['topic'];
    $detail=$_POST['detail'];
    $name=$_POST['name'];
    $email=$_POST['email'];
    
    $datetime=?><html><script type="text/javascript">
    
    var d = new Date();
    document.write(d.getHours());
    document.write(".");
    document.write(d.getMinutes());
    document.write(".");
    document.write(d.getSeconds());
    
    </script> </html>//create date time
    <?php
    $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";
    $result=mysql_query($sql);
    
    if($result){
    echo "Successful<BR>";
    echo "<a href=main_forum.php>View your topic</a>";
    }
    else {
    echo "ERROR";
    }
    mysql_close();
    ?>

  10. i have a code to write the time of a post to a database, this code is meant to detect time zones, but it doesn't detect daylight saving. How can i add this

    $datetime=date("jS of M Y h:ia e");

     

    e

    is the code for the timezone detection

  11. with this code, i get the else function, how can i find where the error is?

    <?php
    require_once 'db_connect.php';
    require_once 'config_table.inc.php';
    
    // get data that sent from form
    $topic=$_POST['topic'];
    $detail=$_POST['detail'];
    $name=$_POST['name'];
    $email=$_POST['email'];
    
    $datetime=date("d/m/y h:i:s"); //create date time
    
    $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";
    $result=mysql_query($sql);
    
    if($result){
    echo "Successful<BR>";
    echo "<a href=main_forum.php>View your topic</a>";
    }
    else {
    echo "ERROR";
    }
    mysql_close();
    ?>

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