I have a form calling below php snippet, and all it does is echo ".dat" on a blank page... what gives? -
<?php
-
$username = $_POST[$uname];
-
$fname = $username . ".dat";
-
if (!file_exists($fname)) { //uniqueness
-
chdir('data');
-
copy('blank.dat',$fname);
-
$handle = fopen($fnname,"a");
-
fwrite($handle, $_POST[$password]);
-
chdir('..');
-
echo $fname;
-
}
-
else {
-
echo "not unique";
-
}
-
?>
14 1228
Heya, DementedGimp. Welcome to TSDN!
Looks like it's not picking up $_POST[$uname]. Did you mean: - $username = $_POST['uname']
?
Tried that... still nothing... using Apache 1.3 & php 5
Heya, DementedGimp.
The problem is that $username has no value. Try putting this at the top to see what is being submitted with the form:
pbmods,
all I get is ;Array()' as output!
Heya, DementedGimp.
So $_POST is empty; therefore $_POST['uname'] has no value.
pbmods,
here is the calling form: -
<?php
-
echo "Input user info:<br>";
-
echo "<form method='POST' action='infoinput.php'>";
-
echo "<br>Please enter username: <input type='text' name='$uname'>";
-
echo "<br>Please enter password: <input type='text' name='$password'>";
-
echo "<input type='submit'>";
-
echo "</form>";
-
?>
It doesn't see $uname, i guess.....
pbmods,
here is the calling form:
<?php
echo "Input user info:<br>";
echo "<form method='POST' action='infoinput.php'>";
echo "<br>Please enter username: <input type='text' name='$uname'>";
echo "<br>Please enter password: <input type='text' name='$password'>";
echo "<input type='submit'>";
echo "</form>";
?>
It doesn't see $uname, i guess.....
Why use a variable as the name of the input?
Take away the dollar sign and then $_GET['uname'] and the same for password.
pbmods,
I striipped all the php out of the calling form, and it works... thanks pbmods
Arrrgh, pb, it worked for two input variables, but when I added more input vars:
Input user info:[php]
<br>
<form name="userinput" method="POST" action="infoinput.php">
<br>Please enter username: <input type="text" name"$username">
<br>Please enter last name: <input type="text" name="$lastname">
<br>Please enter first name: <input type="text" name="$firstname">
<br>Please enter sex: <input type="text" name="$sex">
<br>Please enter date of birth: <input type="text" name="$dob">
<br>Please enter password: <input type="text" name="$password">
<br>Please enter address1: <input type="text" name="$address1">
<br>Please enter address2: <input type="text" name="$address2">
<br>Please enter city: <input type="text" name="$city">
<br>Please enter statte: <input type="text" name="$state">
<br>Please enter zipcode: <input type="text" name="$zipcode">
<input type="submit">
</form>
[/php]
it didn't see $username, but saw the rest. here is infoiinput.php:
[php]
<?php
print_r($_POST);
$uname = $_POST['$username'];
$pw = $_POST['$password'];
$fname = $uname . ".dat";
if (!file_exists($fname)) { //uniqueness
chdir('data');
copy('blank.dat',$fname);
$handle = fopen($fname,"a");
fputs($handle, $pw);
chdir('..');
// echo $fname;
}
else {
echo "not unique";
}
?>
[/php]
I know, you're going to ask why not mysql, but mysql just refuses to work for me.
Heya, DementedGimp.
Please use CODE tags when posting source code:
[CODE=php]
PHP code goes here.
[/CODE]
Have a look at this page.
PB,
I stripped the $ from the code, but it still does not see 'username'.... here the code: -
Input user info:<br>
-
<form name="userinput" method="POST" action="infoinput.php">
-
<br>Please enter username: <input type="text" name"username">
-
<br>Please enter last name: <input type="text" name="lastname">
-
<br>Please enter first name: <input type="text" name="firstname">
-
<br>Please enter sex: <input type="text" name="sex">
-
<br>Please enter date of birth: <input type="text" name="dob">
-
<br>Please enter password: <input type="text" name="password">
-
<br>Please enter address1: <input type="text" name="address1">
-
<br>Please enter address2: <input type="text" name="address2">
-
<br>Please enter city: <input type="text" name="city">
-
<br>Please enter statte: <input type="text" name="state">
-
<br>Please enter zipcode: <input type="text" name="zipcode">
-
<input type="submit">
-
</form>
-
here's the code for infoinput.php: -
<?php
-
print_r($_POST);
-
$uname = $_POST['username'];
-
$pw = $_POST['password'];
-
$fname = $uname . ".dat";
-
if (!file_exists($fname)) { //uniqueness
-
chdir('data');
-
copy('blank.dat',$fname);
-
$handle = fopen($fname,"a");
-
fputs($handle, $pw);
-
chdir('..');
-
}
-
else {
-
echo "not unique";
-
}
-
?>
-
Heya, DementedGimp.
What is the output of print_r($_POST) when you submit the form?
Pb,
Everything but the first variable username, which is weird, 'cause it worked with just 2 variables.....
Array ( [lastname] => jacques [firstname] => pages [sex] => m [dob] => 9/28/64 [password] => miki69 [address1] => dddddddddd [address2] => ssssssss [city] => ggggggg [state] => rii [zipcode] => 02842 )
Sign in to post your reply or Sign up for a free account.
Similar topics
by: milkyway |
last post by:
Hello,
I have an HTML page that I am trying to import 2 .js file (I created)
into. These files are: row_functions.js and data_check_functions.js.
Whenever I bring the contents of the files into...
|
by: Craig Keightley |
last post by:
Please help, i have attached my page which worksin IE but i cannnot get the
drop down menu to fucntion in firefox. Any one have any ideas why?
Many Thanks
Craig
...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: Alpha |
last post by:
I have a Window based application that shows up still running in the task
manager when I close it. It reaches the "this.close" statement and then it
stops at the "}" at the section of the...
|
by: Rahul |
last post by:
Hi Everybody
I have some problem in my script. please help me. This is script file.
I have one *.inq file. I want run this script in XML files. But this
script errors shows . If u want i am...
|
by: treelife |
last post by:
I'm getting and internal server error when | run the following
mod_python script. I am actually trying to run Django.
Script:
from mod_python import apache
def handler(req):...
|
by: KitKat |
last post by:
I need to get this to go to each folders: Cam 1, Cam 2, Cam 4, Cam 6, Cam 7,
and Cam 8. Well it does that but it also needs to change the file name to
the same folder where the file is being...
|
by: nt91rx78 |
last post by:
Our college changes 18 weeks semester to 16 semester, so our CS professor cannot finish teaching the last important chapter which is related with my problw\em.
This is program C problem
Anyone...
|
by: alivip |
last post by:
I integrat program to be GUI using Tkinter I try browser direction
as you can see
# a look at the Tkinter Text widget
# use ctrl+c to copy, ctrl+x to cut selected text,
# ctrl+v to...
|
by: alivip |
last post by:
How can I get every Token (word) and PreviousToken(Previous word) From multube files and frequency of each two word
my code is trying to get all single word and double word (every Token (word) and...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
| | |