Jump to content

cmr

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Posts posted by cmr

  1. I am working on a menu that is a list of links, which when clicked open up sub links below using javascript as well as navigating to a new page which also links to the anchor of the item you clicked so the item you clicked will be visible in the scrollable div.

     

    Problem i'm having is that when it scrolls to the anchor inside the div its then scroll half way down the page

     

    I'm wondering how to solve it. Either by getting it to scroll back to the top of the page after it has scrolled to the correct point inside the div, or getting the div to scroll itself. Have found some methods but using static values to scroll which wont help me as the height differs.

  2. Is there a better way to do it than i currently am using?

     

    Simply echos the value in the selected option that will otherwise be blank, so this makes it impossible for the user to select no input. Any help much apreciated.

     

    $e_s_y  = $_POST['frm_e_s_y'];

     

    <select id="frm_e_s_y" name="frm_e_s_y">

    <option selected="selected"><?php echo $e_s_y ?></option>

    <?php

    for($i=2007,$a=2015;$i<=$a;$i++)

    {

    echo "<option>$i</option>";

    }

    ?>

    </select>

  3. have never come across this problem before but have created a drop down selection for date so it goes 1-31 but when you click it, it simply closes itself unless you hold it down, i guess because the list is placed differently as there are too many options to display. Anyone experienced this before and know if theres a way to solve it?

     

    Edit: it seems to be selecting another drop down box i have when it closes the drop down list but i dont have problem with that one. Doesnt seem to be because of the fact its positioned differently

  4. Have no problem with this on any of my other pages, have checked for white space and even unformatted it to check and put it into Notepad instead of TextPad but no joy there. Dont know if its anything to do with cookies, any help much apreciated.

     

    Errors:

     

    Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\include\header.php:7) in C:\wamp\www\log_out.php on line 9

     

    Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\include\header.php:7) in C:\wamp\www\log_out.php on line 10

     

    Header.php

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <title></title>

    <link type="text/css" href="style.css" rel="stylesheet" media="screen" />

    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

    <meta name="resource-type" content="document" />

    </head>

    <body>

     

    <div id="container">

    <div id="header">

    <div class="header01"></div>

    <div class="header02">

    <div id="header_text">

    <?php

    if (!isset($_COOKIE['cookie_user']) && !isset($_COOKIE['cookie_pass']))

    {

    ?>

    Login

    <form method="POST" action="log_in.php">

    Username <input type="text" name="frm_user" id="frm_user" size="20" /><br />

    Password <input type="password" name="frm_pass" size="20" /><br />

    <input type="submit" value="Submit" name="sub" />

    <input type="reset" value="Reset" name="res" />

    </form>

     

    <a href='register.php'>Register</a>

    <a href='password.php'>Lost Password?</a><br />

     

    <?php

    }

    else

    {

    $user = $_COOKIE['cookie_user'];

    echo "<h3>Welcome Back</h3>";

    echo "<h4>$user</h4>";

    echo "<h4><a href='log_out.php'>Log Out</a></h4>";

    }

    ?>

    </div>

    </div>

    <div class="header03"></div>

    </div>

     

    log_out.php

     

    <?php

    include('include/header.php');

    include('include/menu.php');

     

     

    $time = time();

    if (isset($_COOKIE['cookie_user']) && isset($_COOKIE['cookie_pass']))

    {

    setcookie ("cookie_user", "", $time - 300000);

    setcookie ("cookie_pass", "", $time - 300000);

    echo "<h1>Log Out</h1>";

    echo "<p>All Cookies Cleared</p>";

    echo "<p><a href='index.php'>Back to Home</a></p>";

    }

     

    include('include/side.php');

    include('include/footer.php');

    ?>

  5. Well its my first try at OOP in PHP. It may not be strictly OOP at the moment but it make it a lot more readable than it was before.

     

    Apart from messing up the variables im still not sure where im going wrong. the registration function is supposed to automatically load and load functions as necessary. Thats what im attempting to do anyway sorry if its basic stuff im getting wrong but i have to start somewhere.

  6. I have recently decided to make my current project OOP have read a few tutorials on it but im not expert but had a go at making my registration page object orientated. Can someone tell me where im going wrong and point me in the right direction please. much apreciated

     

    <?php

    include('connect.php');

     

    class Registration

    {

    $first=$_POST['frm_first'];

    $last=$_POST['frm_last'];

     

    $first_lower=strtolower($first);

    $last_lower=strtolower($last);

    $user=$first . "." . $last;

     

    $pass=md5($_POST['frm_pass']);

    $dept=$_POST['frm_dept'];

    $job=$_POST['frm_job'];

    $email=$_POST['frm_email'];

    $phone=$_POST['frm_phone'];

    $mobile=$_POST['frm_mobile'];

    $qual=$_POST['frm_qual'];

     

    $errArray[] = 0;

    $error = 'false';

     

    function Registration()

    {

    if(empty($_POST))

    {

    $registration = new Registration();

    $registration->displayForm();

    }

    else

    {

    $registration->errorCheck()

     

    if($error != 'true')

    {

    $registration->registerUser();

    }

    if($error = 'true')

    {

    $registration->displayErrors();

    $registration->displayForm();

    }

    }

    }

     

    function errorCheck()

    {

    if(empty($_POST['frm_first']))

    {

    array_push($errArray, "Please specify a First name");

    $error = 'true';

    }

    if(empty($_POST['frm_last']))

    {

    array_push($errArray, "Please specify a Lastname");

    $error = 'true';

    }

    if(empty($_POST['frm_pass']))

    {

    array_push($errArray, "Please specify a Password");

    $error = 'true';

    }

    if(empty($_POST['frm_dept']))

    {

    array_push($errArray, "Please specify a Department");

    $error = 'true';

    }

    if(empty($_POST['frm_job']))

    {

    array_push($errArray, "Please specify a Job Title");

    $error = 'true';

    }

    if(empty($_POST['frm_email']))

    {

    array_push($errArray, "Please specify an Email");

    $error = 'true';

    }

    }

     

    public function displayForm()

    {

    ?>

    <p>Fill in the form below with your details</p>

    <form class="frm" action="register.php" method="post">

    First Name <input type="text" name="frm_first" maxlength="20" value="<?php echo $first ?>" /><br />

    Last Name <input type="text" name="frm_last" maxlength="20" value="<?php echo $last ?>" /><br />

    Password <input type="password" name="frm_pass" maxlength="20" value="" /><br />

    Department

    <select name="frm_dept">

    <option value="<?php echo $dept ?>"><?php echo $dept ?></option>

    <option value="F1">F1</option>

    <option value="F2">F2</option>

    <option value="F3">F3</option>

    <option value="F4">F4</option>

    <option value="F5">F5</option>

    <option value="F6">F6</option>

    <option value="F7">F7</option>

    <option value="F8">F8</option>

    <option value="F9">F9</option>

    </select><br />

    Job Title <input type="text" name="frm_job" maxlength="40" value="<?php echo $job ?>" /><br />

    Email <input type="text" name="frm_email" maxlength="40" value="<?php echo $email ?>" /><br />

    Phone <input type="text" name="frm_phone" maxlength="15" value="<?php echo $phone ?>" /><br />

    Mobile <input type="text" name="frm_mobile" maxlength="15" value="<?php echo $mobile ?>" /><br />

    Qualifications <input type="frm_qual" name="county" maxlength="20"  value="<?php echo $qual ?>" /><br />

    <input type="submit" value="Submit" /><input type="reset" value="Reset" />

    </form>

    <a href='index.php'>Back to Main</a><br />

    <?php

    }

     

    public function registerUser()

    {

    mysql_connect($sql_server,$sql_username,$sql_password);

    mysql_select_db($sql_database) or die( "Unable to select database");

     

    $query = "INSERT INTO staff VALUES ('$user','$pass','$first','$last','$qual','$email','$phone','$mobile','$dept','$job','NULL','n','n');";

     

    $result = mysql_query($query);

     

    mysql_close();

     

    if (!$result)

    {

    array_push($errArray, "User Account Already Exists");

    $error = 'true';

    }

    else

    {

    echo "Registered $user<br />";

    echo "<a href='index.php'>Back to Main</a><br />";

    }

    }

     

    public function displayErrors()

    {

    echo "There were errors in your form:<br />";

    $count = 0;

    reset($errArray);

    foreach ($errArray as $value)

    {

    if ($count != 0)

    {

    echo "<li>" . $value . "</li>";

    }

    $count++;

    }

    }

    }

    ?>

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