473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to transfer variables from a .php script to an .html page that will display the results.

Hi,

I'm a newbie in php/mysql programming,really am.
I'm working on a web-site that allows registration and posterior
logging in. Already registered user logs in with valid username and
password. Username and password are validated against a MySQL database
of personal data that contains these fields among others.
This is done by means of a PHP script that redirects to a "page2.html"
(if user and password non-existent) OR it redirects to a
"page3.html",if username and password exist and match in the database.
Following is part of the code:

<?php
function RedirectURL($url)
{ // This calls javascript
$redir = "<script language=\"javascript\">location.href=\"$url\"</script>\n";
return $redir;
}
?> // got this function from the groups. thanks.

<?php
..
..
..
$query = "SELECT password FROM all_pers_data WHERE username =
'$loginID' ";

$result = mysql_query($query) or die
(RedirectURL('http://xxx.xxx.xxx.xxx:XXXX/ / /page2.html'));
$numentries = mysql_numrows($result); //Numero de filas
returned. mysql_close($link);

$correct_username = $loginID;
$correct_password = mysql_result($result,0,"password"); //assumming
there is only one match...
if (strcasecmp($correct_username,$loginID) ||
strcasecmp($correct_password,$loginPW) ) {
die(RedirectURL('http://xxx.xxx.xxx.xxx:XXXX/ / /page2.html'));
//loginID or password that do not match
}
else {
die(RedirectURL('http://xxx.xxx.xxx.xxx:XXXX/ /
/page3.html'));//ASSERT, print out info in .html page.
}
..
..
..

?>

My question is: how can I transfer the variable "$result" from my PHP
to the .html pages, so that I'm able to print out the info for the
existent user through page3.html. In other words, i would like to
re-use "$result" from the php/mysql query; this, in order to display
information about the successfully logged in user.

Any help or suggestions i will appreciate a lot. Thanks.

Ivan
Jul 23 '05 #1
3 1226
da******@hotmail.com wrote:
My question is: how can I transfer the variable "$result" from my PHP
to the .html pages, so that I'm able to print out the info for the
existent user through page3.html. In other words, i would like to
re-use "$result" from the php/mysql query; this, in order to display
information about the successfully logged in user.

Any help or suggestions i will appreciate a lot. Thanks.


<url: http://jibbering.com/faq/#FAQ4_18 />

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2
["Followup-To:" header set to comp.lang.php.]
da******@hotmail.com wrote:
[snip]
My question is: how can I transfer the variable "$result" from my PHP
to the .html pages, so that I'm able to print out the info for the
existent user through page3.html. In other words, i would like to
re-use "$result" from the php/mysql query; this, in order to display
information about the successfully logged in user.

Any help or suggestions i will appreciate a lot. Thanks.


Use session variables: http://www.php.net/session

When you know the $result save it in a session variable

$_SESSION['SQLResult'] = $result;

and, afterwards, when you need the same result use the value saved in
the session variable

echo 'Saved result is: ', $_SESSION['SQLResult'];

Don't forget to start the session support in *every* page that uses the
$_SESSION array
--
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
Jul 23 '05 #3
.oO(da******@hotmail.com)
function RedirectURL($url)
{ // This calls javascript
$redir = "<script language=\"javascript\">location.href=\"$url\"</script>\n";
return $redir;
}


header("Location: $url");

http://www.php.net/header

Micha
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: danubian | last post by:
Hi, I'm a newbie in php/mysql programming,really am. I'm working on a web-site that allows registration and posterior logging in. Already registered user logs in with valid username and...
1
by: dawnunder | last post by:
eg. Someone fills out 3 fields. (There will be more but this is just to give you an idea) 1. Country? 2. State? 3. City I want this script to generate a web page and list the people by
1
by: Joe | last post by:
I am trying to write a Perlscript to be used with some HTML pages. Here is how it works: 1.. The first HTML page has a form which requests for user input. Then it passes the QUERY_STRING...
1
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast,...
4
by: JA | last post by:
I have this little tell-a-friend script that will send out a link back to the site. I want to put a link on my product pages that will go to the script, and have the script display the product...
6
by: StephenMcC | last post by:
Hi All, Got a quick query in relation to the Server.Transfer method available in IIS 5+/ASP. I've got an issue where I want to take a portion of an online app and extract this out into a web...
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
5
by: Nedu N | last post by:
Hi All, I am facing a typical problem in my .NET application with the pop-up script messages. The thing is that its working fine when i run on my development machine but not running in expected...
8
by: p3t3r | last post by:
I am using .NET2 and have a number of aspx pages. On each page is a LinkButton that performs a server.transfer() to another page. If we use page names A,B,C,D,E as an example. I start on page A...
5
by: quirk | last post by:
I am trying to write a script where a page is populated with some maths questions, user answers them (it's timed but I've left this bit out), gets results on same page and ajax takes their score,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.