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

passing the value from a text box to a varible

3
Hi, this is probably a stupid question.

Im trying to declare a varible to have the value of that in a text box

when i declare the varible is there a way to give it the value in a text box called area.

i was trying the way below but it puts the word username in the database

$userName = 'username';

then in the form i used

<p><b>User Name:</b> <input type="text" name="userName" size="10" maxlength="20" value="<?php ($_post['$userName']) ?>" /></p>

doesnt seem to work thought
any ideas
Jan 15 '07 #1
2 2286
Aido82
3
this is all the code

<html>
<body>
<link rel=stylesheet href="Stylesheet.css" type="text/css">
</body>

<?
//declar varibles

//$userName = ;
$userName=$_POST['userName'];
$title=$_POST['title'];
//$tel=$_POST['tel'];




$conn = mysql_connect("localhost", "root", "") or die('could not connect to mysql' .mysql_error());

mysql_select_db('customer', $conn) or die('could not connect to DB' .mysql_error());

// Make the query.
//$query = "INSERT INTO customerdetails (userName, password, title, custFirstName, custLastName, email) VALUES ('$userName', '$password', '$title' '$custFirstName', '$custLastName', '$email')";

$query = "INSERT INTO `customerdetails` ( `custID` , `userName` , `password` , `title` , `custFirstName` , `custLastName` , `email` , `address1` , `address2` , `address3` , `country` , `telephone` )

VALUES (NULL , '$userName', '$password', '$title', '$custFirstName', '$custLastName', '$email', '312 daneswell road', '2glasnevin', '2dublin 9', '2ireland', '21800 111 111')";


$result = @mysql_query ($query); // Run the query.

//echo '<p><b>You have been registered!</b></p>';

mysql_close(); // Close the database connection.


?>

<form action="registered.php" method="post"><fieldset>
<legend>Enter your information in the form below:</legend>

<p><b>User Name:</b> <input type="text" name="userName" id ="userName" size="10" maxlength="20" value="<?php ($_post['$userName']) ?>" /></p>

<p><b>Password:</b> <input type="password" name="password" id ="password" size="20" maxlength="20" value ="<?php if (isset($_POST['password'])) echo $_POST['password']; ?>"/></p>

<p><b>Title:</b> <input type="text" name="title" id ="title" size="15" maxlength="15" value="<?php if (isset($_POST['title'])) echo $_POST['title']; ?>" /></p>

<p><b>First Name:</b> <input type="text" name="custFirstName" size="15" maxlength="15" value="<?php if (isset($_POST['custFirstName'])) echo $_POST['custFirstName']; ?>" /></p>

<p><b>Last Name:</b> <input type="text" name="custLastName" size="30" maxlength="30" value="<?php if (isset($_POST['custLastName'])) echo $_POST['custLastName']; ?>" /></p>

<p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>



</fieldset>

<div align="center"><input type="submit" name="submit" value="Register" /></div>

</form>

</html>
Jan 15 '07 #2
cassbiz
202 100+
this is all the code

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <link rel=stylesheet href="Stylesheet.css" type="text/css">
  4. </body>
  5.  
  6. <?        
  7. //declar varibles
  8.  
  9. //$userName = ;
  10. $userName=$_POST['userName'];
  11. $title=$_POST['title'];
  12. //$tel=$_POST['tel']; 
  13.  
  14.  
  15.  
  16.  
  17. $conn = mysql_connect("localhost", "root", "") or die('could not connect to mysql' .mysql_error()); 
  18.  
  19.         mysql_select_db('customer', $conn) or die('could not connect to DB' .mysql_error());
  20.  
  21.         // Make the query.
  22.             //$query = "INSERT INTO customerdetails (userName, password, title, custFirstName, custLastName, email) VALUES ('$userName', '$password', '$title' '$custFirstName', '$custLastName', '$email')";    
  23.  
  24.             $query = "INSERT INTO `customerdetails` ( `custID` , `userName` , `password` , `title` , `custFirstName` , `custLastName` , `email` , `address1` , `address2` , `address3` , `country` , `telephone` ) 
  25.  
  26.             VALUES (NULL , '$userName', '$password', '$title', '$custFirstName', '$custLastName', '$email', '312 daneswell road', '2glasnevin', '2dublin 9', '2ireland', '21800 111 111')";
  27.  
  28.  
  29.             $result = @mysql_query ($query); // Run the query.
  30.  
  31.                 //echo '<p><b>You have been registered!</b></p>';
  32.  
  33.         mysql_close(); // Close the database connection.
  34.  
  35.  
  36. ?>
  37.  
  38. <form action="registered.php" method="post"><fieldset>
  39. <legend>Enter your information in the form below:</legend>
  40.  
  41. <p><b>User Name:</b> <input type="text" name="userName" id ="userName" size="10" maxlength="20" value="<?php ($_post['$userName']) ?>" /></p>
  42.  
  43. <p><b>Password:</b> <input type="password" name="password" id ="password" size="20" maxlength="20" value ="<?php if (isset($_POST['password'])) echo $_POST['password']; ?>"/></p>
  44.  
  45. <p><b>Title:</b> <input type="text" name="title" id ="title" size="15" maxlength="15" value="<?php if (isset($_POST['title'])) echo $_POST['title']; ?>" /></p>
  46.  
  47. <p><b>First Name:</b> <input type="text" name="custFirstName" size="15" maxlength="15" value="<?php if (isset($_POST['custFirstName'])) echo $_POST['custFirstName']; ?>" /></p>
  48.  
  49. <p><b>Last Name:</b> <input type="text" name="custLastName" size="30" maxlength="30" value="<?php if (isset($_POST['custLastName'])) echo $_POST['custLastName']; ?>" /></p>
  50.  
  51. <p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>
  52.  
  53.  
  54.  
  55. </fieldset>
  56.  
  57. <div align="center"><input type="submit" name="submit" value="Register" /></div>
  58.  
  59. </form>
  60.  
  61. </html>
  62.  

you are already defining $_POST['$userName']; in the beginning

Expand|Select|Wrap|Line Numbers
  1. <p><b>User Name:</b> <input type="text" name="userName" id ="userName" size="10" maxlength="20" value="<?php $userName ?>" /></p>
Jan 15 '07 #3

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

Similar topics

12
by: harry | last post by:
I have an object that's passed in to a function as a parameter i.e public boolean getProjectTitle(ProjectHeader_DTO obj) {...} If I then call a method on this object inside the function i.e...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
4
by: Xero | last post by:
Hello. I am using vb.net. There are two forms in my project. One is 'base' and the other one is 'savecurrent'. There is a value stored in a textbox called 'qc_a' in 'base'. I want to inherit...
10
by: John Bailo | last post by:
I want to pass a SqlCommand object as a input parameter to a method. I want to pass the SqlCommand "by value" so that any updates to the original object are *not* reflected in the object within...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
2
by: nagle.p | last post by:
Ok, Im writting a plug-in for a application and the class the I have to derive from has a warp() funtion that gets called that is part of the base class. I need to pass a varible into this...
8
by: Peter | last post by:
I will excute the code below to get MethodName array. These codes are edited under VS2003. Now I want to upgrade it to VS2005,but VS2005 gives me a varning message: The varible "sSourceMethodName"...
4
by: TARUN | last post by:
Hello All, Please helping to understand this .. as i ma novice for .Net technology.. What are the different possible way to send the value from one to another in asp.NET using C#.NET ?? I...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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.