473,830 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP and XML - using hidden forms as variables

3 New Member
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.p hp 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="localhos t"; // Host name
$username="root "; // Mysql username
$password="xxxx xxxxx"; // Mysql password
$db_name="test" ; // Database name
$tbl_name="Stud ent"; // 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=$_P OST['studentusernam e'];
$mypassword=$_P OST['studentpasswor d'];

//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='$myus ername' and userPassword='$ mypassword'";
$result=mysql_q uery($sql);

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

if($count==1){

session_registe r("studentusern ame");
session_registe r("studentpassw ord");
header("locatio n:welcome.xml") ;

}
else {

header("locatio n:failedlogin.x ml");

}


?>
Feb 10 '08 #1
2 1923
ronverdonk
4,258 Recognized Expert Specialist
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='$myusern ame' />"
echo "<input type='hidden' name='psw' value='$mypassw ord' />"
[/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
adamace5o
3 New Member
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='$myusern ame' />"
echo "<input type='hidden' name='psw' value='$mypassw ord' />"
[/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.p hp 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
19886
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 the site, because the page id is null, PHP loads the default design. But when I execute one of my other pages which has a form on it, because I cannot pass back the id of the page that the form is on (the "submit" GET's the desired page id...
5
7710
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 take the place of the following standard submit button: <form action="ProductQuery.cfm" name="LineCode" method="post"> <input type="hidden" name="Year" value="#GetProducts.Year#"> <input type="hidden" name="Make" value="#GetProducts.Make#">
3
9281
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 work on FireFox or Netscape. What could be wrong? The function: function setActiveTab(tabNo) {
3
8338
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 display the same 2 jpg images (logos). I do not want to store the images in the forms themselves as, once in Access, they increase so much the DB file size.
8
2672
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? Is there a method for detecting what page the user came from when a page is accessed using history.go()? -- Ed Jay (remove M to respond by email)
9
1537
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 object of session class. I am creating this object in the login page. Now how can i make this object persist between subsequent page requests. and i dont want to use GET method. Is it sensible to use hidden fields OR will i have to create a new
3
3164
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") (i).value; }
14
4267
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 something I'm missing header-wise that keeps me from making this work on my work system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do though I'm using 5.x at home), and MySQL as the database. Thanks VERY much for any help or...
19
248308
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 this data is essential to any developer. This article is a basic tutorial on how to user HTML Forms, the most common method of data collection. Assumptions - Basic HTML knowledge. - Basic PHP knowledge. HTML Forms A common and simple way of...
0
10774
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10491
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10526
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10206
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9315
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.