Film-Tech Cinema Systems
Film-Tech Forum ARCHIVE


  
my profile | my password | search | faq & rules | forum home
  next oldest topic   next newest topic
» Film-Tech Forum ARCHIVE   » Community   » Film-Yak   » PHP coding help

   
Author Topic: PHP coding help
Andrew McCrea
Jedi Master Film Handler

Posts: 645
From: Winnipeg, Manitoba, Canada
Registered: Nov 2000


 - posted 12-01-2007 09:42 AM      Profile for Andrew McCrea   Author's Homepage   Email Andrew McCrea   Send New Private Message       Edit/Delete Post 
Hello!

I'm learning PHP right now (from "PHP and MySQL for Dummies").

I've been using some of their code examples in the book to build the member's only section.

I was wondering if anyone could help me figure out why this page won't load to the next member_page.php.

This is the code to the Login page (I removed the registering opion):
[CODE]<?php
/* Program: Login.php
* Desc: Login program for the Members Only section of
* the pet store. It provides two options:
* (1) login using an existing Login Name and
*/
session_start(); # 9
include("connect.inc"); #10
switch (@$_POST['do']) #11
{
case "login": #13
$cxn = mysqli_connect($host,$user,$passwd,$dbname)
or die ("Couldn't connect to server."); #15

$sql = "SELECT loginName FROM member
WHERE loginName='$_POST[fusername]'"; #18
$result = mysqli_query($cxn,$sql)
or die("Couldn't execute query."); #20
$num = mysqli_num_rows($result); #21
if ($num > 0) // login name was found #22
{
$sql = "SELECT loginName FROM member
WHERE loginName='$_POST[fusername]'
AND password=md5('$_POST[fpassword]')";
$result2 = mysqli_query($cxn,$sql)
or die("Couldn't execute query 2.");
$num2 = mysqli_num_rows($result2);
if ($num2 > 0) // password is correct #30
{
$_SESSION['auth']="yes"; #32
$logname=$_POST['fusername'];
$_SESSION['logname'] = $logname; #34
$today = date("Y-m-d h:i:s"); #35
$sql = "INSERT INTO login (loginName,loginTime)
VALUES ('$logname','$today')";
$result = mysqli_query($cxn,$sql)
or die("Can't execute insert query.");
header("Location: member_page.php"); #40
}
else // password is not correct #42
{
$message="The Login Name, '$_POST[fusername]'
exists, but you have not entered the
correct password! Please try again.<br>";
include("login_form.inc"); #47
}
} #49
elseif ($num == 0) // login name not found #50
{
$message = "The Login Name you entered does not
exist! Please try again.<br>";
include("login_form.inc");
}
break; #56

default: #223
include("login_form.inc");
}
?>
[/CODE]

 |  IP: Logged

Roger Summars
Film Handler

Posts: 11
From: Buffalo, Oklahoma, USA
Registered: Sep 2007


 - posted 12-03-2007 11:10 AM      Profile for Roger Summars   Author's Homepage   Email Roger Summars       Edit/Delete Post 
just a quick shot-in-the-dark here....

Have you thought about changing line 40 to include the full URL, such as:

header('Location: http://www.myexample.com/member_page.php');

Note I changed to single quotes also, you might have to try it both ways.

Roger

 |  IP: Logged

Mark J. Marshall
Film God

Posts: 3188
From: New Castle, DE, USA
Registered: Aug 2002


 - posted 12-03-2007 11:57 AM      Profile for Mark J. Marshall     Send New Private Message       Edit/Delete Post 
Relative paths should work with the header() function, however if you're calling it from within an include file, remember that the relative path that you need is not the relative path from the included file, but from the main file. This is why I always try to have the full path there, including the "http://" or "https://".

Also, from PHP.net:
quote:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
That means check your "connect.inc" file (and this file) for any blank lines or other output. There can't be anything sent to the browser before the header() function is called.

 |  IP: Logged



All times are Central (GMT -6:00)  
   Close Topic    Move Topic    Delete Topic    next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:



Powered by Infopop Corporation
UBB.classicTM 6.3.1.2

The Film-Tech Forums are designed for various members related to the cinema industry to express their opinions, viewpoints and testimonials on various products, services and events based upon speculation, personal knowledge and factual information through use, therefore all views represented here allow no liability upon the publishers of this web site and the owners of said views assume no liability for any ill will resulting from these postings. The posts made here are for educational as well as entertainment purposes and as such anyone viewing this portion of the website must accept these views as statements of the author of that opinion and agrees to release the authors from any and all liability.

© 1999-2020 Film-Tech Cinema Systems, LLC. All rights reserved.