PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Milan
Forum Commoner
Posts: 97 Joined: Wed May 17, 2006 6:08 pm
Post
by Milan » Tue May 23, 2006 6:03 pm
Code: Select all
$testrx = $_POST['file'];
switch ($testrx) {
case "" :
if ($row_userinfo['Logo']=="nologo.gif"){
$logox = "nologo.gif";
}
else
$logox = $_COOKIE['USERNAME'].".jpg";
break;
}
I have a input filed type="file" but script always writes the
Code: Select all
$logox = $_COOKIE['USERNAME'].".jpg";
Did i do something wrong?
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Tue May 23, 2006 6:14 pm
Milan wrote:
Code: Select all
<?php
$testrx = $_POST['file'];
switch ($testrx) {
case "" :
if ($row_userinfo['Logo']=="nologo.gif"){
$logox = "nologo.gif";
}
else
{
$logox = $_COOKIE['USERNAME'].".jpg";
}
break;
}
?>
Where does the array var $row_userinfo['Logo'] get set? What is it's value and how does it relate to $_POST['file']?
Milan
Forum Commoner
Posts: 97 Joined: Wed May 17, 2006 6:08 pm
Post
by Milan » Tue May 23, 2006 6:20 pm
$row_userinfo['Logo'] get's it's value from the database ( table users, field - logo)
$_POST['file'] get's it's value from the form1 textbox (<input name="file" type="file" class="text3" value="" size="32"> )
i want to do the following; in case the "file" field has not changed script will leave the old user logo and in case the filed
has changed it will write the USERNAME + extension from a cookie
Code: Select all
$logox = $_COOKIE['USERNAME'].".jpg";
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue May 23, 2006 6:24 pm
do a var_dump on both variable and compare them
Milan
Forum Commoner
Posts: 97 Joined: Wed May 17, 2006 6:08 pm
Post
by Milan » Tue May 23, 2006 6:28 pm
i got NULL NULL
Milan
Forum Commoner
Posts: 97 Joined: Wed May 17, 2006 6:08 pm
Post
by Milan » Tue May 23, 2006 6:30 pm
my bad
it's string(0) "" NULL
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Wed May 24, 2006 2:02 am
use
Code: Select all
$testrx = basename($_FILES['file']['name']);
jmut
Forum Regular
Posts: 945 Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:
Post
by jmut » Wed May 24, 2006 2:04 am
Milan wrote: Code: Select all
$testrx = $_POST['file'];
switch ($testrx) {
case "" :
if ($row_userinfo['Logo']=="nologo.gif"){
$logox = "nologo.gif";
}
else
$logox = $_COOKIE['USERNAME'].".jpg";
break;
}
I have a input filed type="file" but script always writes the
Code: Select all
$logox = $_COOKIE['USERNAME'].".jpg";
Did i do something wrong?
I would have done it like this.
Code: Select all
$testrx = isset($_POST['file']) ? trim($_POST['file']) : "";
switch ($testrx) {
case "" :
// ....
break;
or even
Code: Select all
$testrx = isset($_POST['file']) ? trim($_POST['file']) : "";
switch (true) {
case (empty($testrx)) :
// ....
break;
Milan
Forum Commoner
Posts: 97 Joined: Wed May 17, 2006 6:08 pm
Post
by Milan » Wed May 24, 2006 2:06 am
i'll try it! thanks guys!