Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Redirect to another page based on MYsql result.
Old 11-27-2009, 01:39 PM Redirect to another page based on MYsql result.
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Hi Guys,

Currently when my users login it will output an error if they dont exist.

However now i want my script to run a second mysql query of they dont exist in the first query.

if they exist in the second query i want to place some vars in a session ( up to this point im fine )

Now i want the script to goto a different page..

How do i do the gogot a diff page...

Example, pseudo code ( if thats the right name for it )

PHP Code:

$username 
=  from post;
$pass from post;

// do password encryption etc..

select id from table where username username and pass pass;

if (
it didnt return a row above) {

select from another table where ..................... ;

if ( 
did return a row ) {
redirect user to blaa.html ;


__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE



Last edited by lynxus; 11-27-2009 at 01:40 PM..
lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
 
Register now for full access!
Old 11-27-2009, 02:05 PM Re: Redirect to another page based on MYsql result.
Banned

Posts: 12
Trades: 0
Well depending on the system you're designing you don't need to redirect them to a new page at all.

PHP Code:
$username =  from post;
$pass from post;

// do password encryption etc..
//check your input by running $username and $pass through mysqli_real_escape_string
//you may also want to use a regex to strip all non alphanumeric characters from your username 

$username preg_replace("/[^a-zA-Z0-9 -]/"""$_POST['username']);
//you won't want to use the same for the password since you're probably allowing some symbols in the password but the regex can be changed to allow other characters if you play with it a bit
select id from table where username username and pass pass;

if (
it didnt return a row above) {

select from another table where ..................... ;
//you're wanting to insert some stats into a log here? 

if ( did return a row ) {
either print content of the new page or include content of new pageno need to redirect to another php file ;
otherwise the best way to point to a new page is in your html's form action destination 

chrisrich is offline
Reply With Quote
View Public Profile
 
Old 11-28-2009, 05:20 AM Re: Redirect to another page based on MYsql result.
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Ahhh yeah..
I suppose i could split the page into a few includes and only include parts of the page thats needed.

( I strip_tags , mysql_escape and do a bunch of other things to check they aint sending dodgy stuff my way )

TY

-G
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE



Last edited by lynxus; 11-28-2009 at 05:21 AM..
lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 11-29-2009, 09:20 AM Re: Redirect to another page based on MYsql result.
Super Talker

Posts: 139
Name: John Davis
Trades: 0
You can use
Code:
header('Location: your.link.com');
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
Reply With Quote
View Public Profile Visit MapMaster's homepage!
 
Reply     « Reply to Redirect to another page based on MYsql result.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.88684 seconds with 12 queries