473,394 Members | 1,696 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,394 software developers and data experts.

PHP and XML - using hidden forms as variables

hi, i am trying to use a hidden form as a method of storing varibles for use throughout an online quiz site.

I am using mysql to hold data about the users ie user id username and user password etc.

The information is input into a visible form and then when the user clicks the submit button, a validatelogin.php script is run which takes the data from the input and checks it against the mysql database.

I want to know if there is a way of taking the data from one form, running it thorugh this php script below and then assigning the data from the php variables to the hidden form?

here is the php file:

<?php


session_start();



$host="localhost"; // Host name
$username="root"; // Mysql username
$password="xxxxxxxxx"; // Mysql password
$db_name="test"; // Database name
$tbl_name="Student"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from signup form
$myusername=$_POST['studentusername'];
$mypassword=$_POST['studentpassword'];

//HERE I WANT TO ASSIGN $myusername and $mypassword to the fields in the hidden form called 'hiddenuser' and 'hiddenpassword'


$_SESSION['user']=$myusername;


$sql="SELECT * FROM $tbl_name WHERE userName='$myusername' and userPassword='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){

session_register("studentusername");
session_register("studentpassword");
header("location:welcome.xml");

}
else {

header("location:failedlogin.xml");

}


?>
Feb 10 '08 #1
2 1907
ronverdonk
4,258 Expert 4TB
If you are talking about filling a couple of 'normal' input text fields, you can just put the variable names in the input statement, like:
[php]
echo "<input type='hidden' name='uid' value='$myusername' />"
echo "<input type='hidden' name='psw' value='$mypassword' />"
[/php]

But I only wonder why you do not use the $_SESSION array to carry these variables between different pages?

Ronald
Feb 10 '08 #2
If you are talking about filling a couple of 'normal' input text fields, you can just put the variable names in the input statement, like:
[php]
echo "<input type='hidden' name='uid' value='$myusername' />"
echo "<input type='hidden' name='psw' value='$mypassword' />"
[/php]

But I only wonder why you do not use the $_SESSION array to carry these variables between different pages?

Ronald
I cant seem to use the $_session variable. I am using xml so i am going from index.xml with the login to validatelogin.php to check the crudentials against mysql database and then moving to welcome.xml. i am new to this and support for this combination of xml and php seems sparse.

il try your first suggestion

thanks

Adam

when i say xml i should be saying i have xml files that are transformed by an xsl sheet and then styled using a css. I want the php files to provide my intereation with the database and offer me access to this dynamic data.
Feb 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dariusz | last post by:
I have a problem where I need to pass two variables using GET from a form I have, to solve a page selection problem I have. The code is written that if a new visitor arrives at the front page of...
5
by: sams | last post by:
I've seen this covered before, but I just don't understand Java very well. I apologize if this is a repeat. Basically, I need a text/java style submit form with multiple hidden fields. It would...
3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
3
by: DL | last post by:
Hi, Many questions have already been asked and answered about images in Access... But despite having searched, I have not found an answer to the following question... In my DB, several forms...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
9
by: viz | last post by:
hi, i have written a class for session handling, and i want to use it to keep track of the user. After authenticating the user in login page i am storing the session info like uname etc.. in a...
3
by: prabodhtiwari | last post by:
function submitPartsForm(str) { var count=document.getElementsByName("partId"); for(var i=0;i<count.length;i++) { document.mylist.myNum.value= document.getElementsByName("partNum")...
14
by: jcage | last post by:
Is there any tutorials online for sending email through forms? I can send an email as well as write to my MySQL database from home with the following code but not at work. I think there might be...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.