This topic is locked
[SOLVED]

 I want to re-direct people after a record is added - how

12/16/2010 11:11:31 AM
PHPRunner General questions
K
karmacomposer author

I have the code for redirection:
//** Redirect to another page ****

header("Location: http://www.campstaffusa.com/documents/success.html";);

exit();
However, I want to check and see if the individual entered a record. If they did not enter a record, then they are automatically sent to the add page (this is done). However, any time they log in after that record is added, I want the database to see if they entered a record and if so, redirect them to a web page.
How do I do this?
Mike

J
Jane 12/17/2010

Hi,
use After successful login event to check if there any records for this user.

Here is just a sample:

global $conn;

$strSQLExists = "select * from TableName where UserName='".$username."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data){

header("Location: http://www.campstaffusa.com/documents/success.html";);

exit();

}

else{

header("TableName_add.php");

exit();

}
K
karmacomposer author 12/17/2010



Hi,
use After successful login event to check if there any records for this user.

Here is just a sample:

global $conn;

$strSQLExists = "select * from TableName where UserName='".$username."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data){

header("Location: http://www.campstaffusa.com/documents/success.html";);

exit();

}

else{

header("TableName_add.php");

exit();

}



Perhaps I am wrong, but since this is a global area, wouldn't it affect everyone?
I already have code in the after successful login area (see below). Can I add more code after it?
This is what is already in AFTER SUCCESSFUL LOGIN:
$rstmp = CustomQuery("select UserID from UserValidation where UserName='".$_SESSION["UserID"]."'");

$datatmp = db_fetch_array($rstmp);

$_SESSION["ID"] = $datatmp["UserID"]
In the best of all worlds, for all five types (candidatecc, candidateswt, candidatevisaonly, recruiter and employer), I would love to have code like above direct these groups to a web page (one for each group) if they already added their info (in all cases, only one ADD per person).
for example:
global $conn;

$strSQLExists = "select * from UserValidation where UserName='".$username."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data){

header("Location: http://www.campstaffusa.com/documents/candidatecc.html";);

exit();

}

else{

header("CandidateCC_add.php");

exit();

}

if($data){

header("Location: http://www.campstaffusa.com/documents/candidateswt.html";);

exit();

}

else{

header("CandidateSWT_add.php");

exit();

}

if($data){

header("Location: http://www.campstaffusa.com/documents/candidatevisaonly.html";);

exit();

}

else{

header("CandidateVisaOnly_add.php");

exit();

}

if($data){

header("Location: http://www.campstaffusa.com/documents/recruiters.html";);

exit();

}

else{

header("Recruiters_add.php");

exit();

}

if($data){

header("Location: http://www.campstaffusa.com/documents/employersc.html";);

exit();

}

else{

header("Employers_add.php");

exit();

}
That would be perfect - if it was correct. How would I make this correct and can it co-exist with the code already in the AFTER SUCCESSFUL LOGIN event?
Mike

Sergey Kornilov admin 12/17/2010

It's not clear what you trying achieve with the code that you have currently as it doesn't make much sense. None of code after first if() statement will be executed, ever.

K
karmacomposer author 12/17/2010



It's not clear what you trying achieve with the code that you have currently as it doesn't make much sense. None of code after first if() statement will be executed, ever.


lol
Shows how much I know!
I guess my thinking is that the original suggestion only seems to address the candidatecc group and I need all the groups represented - and since it is in the global area, it just seems like I would need to write a more substantial code fragment to specify all 5 groups. Since my coding experience is limited to visual basic, I really am not sure how to proceed.
The web addresses in each if statement that I wrote send the person to a webpage with various links on it - making the database is little easier for them to utilize (for example, "add my information" would be one button, "search for candidates" would be another, etc.
My idea was that when someone initially adds their info, they will only do it once. This is true for all 5 groups (candidatecc, candidateswt, candidatevisaonly, recruiters and employers). I would like them, the next time they login, to not see the ADD button (and currently have the menu configured to send them directly to the ADD page since they don't need the list page at all. It seems logical to me to send them out of the database at that point and to a webpage that acts as a control panel. So the candidates would see "edit my information" and "view my information" - buttons like that. The links would send them back to the database's specific pages. This I can already do. However, the initial AFTER LOGIN event I cannot seem to figure out.
That is what I am trying to accomplish and that is where I'm at. Hopefully, I have made it much clearer. Yes, my PHP and MySQL coding skills SUCK, but I have learned 200% more now than I did BEFORE I bought PHPRunner and asked you guys a bazillion questions and had you create some code for me. You should be proud that I have learned enough to ask the right questions the wrong way.
Mike