PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 1st, 2004, 12:49 AM
franches franches is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 16 franches User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Forms

I badly need help. I have these codes. I'm doing a statuslog form. Before the user could go the form he/she has to log in.

PHP Code:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"
<
html>
<
head>
</
head>
<
body>
<
form action="validationtest.php" method=post>
<
table align=center style="font-family:arial; font-size:12; border:1 solid #000000;">
<
tr><td colspan=2 align=center bgcolor=#123dd4>LOGIN</td></tr>
<tr><td align=right>Username: </td><td><input type=text name=username size=15></td></tr>
<
tr><td align=right>Password: </td><td><input type=password name=password size=15></td></tr>
<
tr><td align=center colspan=2><input type=submit value=Login></td></tr>
</
table>
</
form>
</
body>
</
html 


then i have a validationtest.php
PHP Code:
<?
session_start
();
 
if (
$username=="" || $password=="")
{
    echo 
"You have to enter your username and password";
    include (
'login.php');
}
 
else
{
    include (
'db.php');
 
$result=mysql_query("select * from StaffTable where PIN='$username'")
             or die (
"cant do it");
 
while (
$row=mysql_fetch_array($result))
{
if (
$row["Password"]==$password )
    {
     
$name=$row["Name"];
     
session_register('Name');
$_SESSION['Name'] = $Name;
 
     include(
'tutor.php');
 
    }
else
    {
    print(
"Please enter your valid Username and Password!");
    include (
'login.php');
    }
}
}
?>


after the person is validated then it will directed to tutor.php and this is where my problem started. The problem is after i press the add hours it goes directly to the login form again. what i really want to happen is that after pressing the add hours it will still go on the same page so that the user will be able to log his/her other activities. I hope someone could help me with the code. i'm doing this for the first time.

thank you very much!!!

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<
html>
    <
head>
         <
title>Workhours form</title>
         <
script type="text/javascript">
 
        var 
total = <?php echo (isset($_POST['work_hours_total']) ? $_POST['work_hours_total'] : "0"); ?>;
 
            function update1()
            {
                document.getElementById("work_hours_total").value = total + Number(document.getElementById("work_hours").value);
                document.getElementById("remaining_hours").value = 7.5 - Number(document.getElementById("work_hours_total").value);
            }
 
    </script>
    </head>
    <body>
        <?php
        session_start
();
 
        
mysql_connect("localhost""root")
        or die( 
"Unable to connect\n"mysql_error() );
 
        
mysql_select_db("TEST")
        or die(
"Unable to select db ".mysql_error()."\n");
 
     if (isset(
$_POST['pin']))
        {
        
$sql"insert into StatusTable (PIN, Activity,RegHours) values ('" $_POST['pin'] . "','" $_POST['activity'] . "','" $_POST['work_hours'] . "')";
        
mysql_query($sql) or die('error making query: ' mysql_error());
        }
 
        
?>
 
        <form action="<?php echo $_SERVER["PHP_SELF"?>" method="post">
 
             <fieldset>
                <div>
                    <label for="pin">PIN :</label> <? echo $username ?><br>
                    <label for="name">Name : </label><? echo $name ?> <br>
                </div>
                <div>
                    <label for="activity">Activity</label>
                    <input id="activity" name="activity" type="text" size="20">
                </div>
                <div>
                    <label for="work_hours">Work Hours</label>
                    <input id="work_hours" name="work_hours" type="text" size="5" onchange="update()">
                </div>
                <div>
                    <label for="work_hours_total">Total Work Hours</label>
                    <input id="work_hours_total" name="work_hours_total" type="text" size="5" value="<?php echo (isset($_POST['work_hours_total']) ? $_POST['work_hours_total'] : ""); ?>" readonly="true">
                </div>
                <div>
                    <label for="remaining_hours">Hours Remaining</label>
                    <input id="remaining_hours" name="remaining_hours" type="text" size="5" value="<?php echo (isset($_POST['work_hours_total']) ? (7.5 $_POST['work_hours_total']) : "7.5"); ?>" readonly="true">
                </div>
                <div>
                    <input type="submit" value="Add hours" name="Add">
                </div>
            </fieldset>
        </form>
    </body>
</html> 

Reply With Quote
  #2  
Old October 1st, 2004, 01:29 PM
xlordt xlordt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: 127.0.0.1
Posts: 20 xlordt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 39 sec
Reputation Power: 0
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt
in tutor.php does it check for users login? also use the empty( ) function with your password and username variables.. another thing
PHP Code:
 $name=$row["Name"];
     
session_register('Name');
$_SESSION['Name'] = $Name

you really dont need to do both.. you can just do
PHP Code:
 $name=$row["Name"];
    
$_SESSION['Name'] = $name

and add auth like ( on other page or etc )
PHP Code:
if( !isSet( $_SESSION['Name'] ) )
{
     print 
'Please login freak!!';
     exit;


Reply With Quote
  #3  
Old October 1st, 2004, 10:55 PM
franches franches is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 16 franches User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i used $name=$row["Name"]; because i need to put the name of the user on my tutor.php on the line <label for="name">Name : </label><? echo $name ?> <br>

on what page do i have to put this? on my tutor.php? and what part of my page i will put this?
Quote:
if( !isSet( $_SESSION['Name'] ) )
{
print
'Please login freak!!';
exit;
}

i'll wait for your response. thanks

Reply With Quote
  #4  
Old October 4th, 2004, 12:02 AM
eddynazrul eddynazrul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: 192.168.1.4
Posts: 21 eddynazrul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You can write in other file and include it at the page that u gonna protect. Or you can just copy and paste it in that page.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Forms


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway