asmith
-
Posts
967 -
Joined
-
Last visited
Posts posted by asmith
-
-
thanks
-
how can i validate a number float with just 2 decimal .
example :
5.01 valid
5 valid
5.001 invalid
0.05 valid
6650.5 valid
1.5 valid
!
-
<select name="test[]" multiple="multiple"> <option value="1"> 55 </option> <option value="2"> 66 </option> <option value="3"> 77</option> </select>
the code above without "[]" , no matter how many choices been selected , overwrite to last one, putting [] , makes all selected a array like :
$test = $_POST[test]; $test[0] $test[1] $test[2] // the values
, why this code won't work properly ? (it has to remain the selected item for each pge reload, but it makes all confusing.mixed
<?php echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" >'; $options = array ("1" => "55","2" => "66","3" => "77"); echo '<select name="test[]" multiple="multiple">'; $test = $_POST[test]; $i = count($test); $a = 0; while(list($aa,$bb) = each($options)) { if ($a < $i){ if ((isset($_POST['test1'])) AND ($test[$a] == $aa)) {$sel = 'selected="selected"';$a++;} } echo '<option value='.$aa.' '.$sel.'>'.$bb.'</option>'; } echo '<input type="submit" name="test1" value="test" /></select></form>'; ?>
(BTW any more simple idea ? less coding ? )
-
ooh yea, it will work i guess, havn't tried yet , but understood what you did there ! (90%)
thank you so much !
that 1 => im 1, what it has todo with the code exactlly ? (10% ^^ )
-
the id you mentioned in the code , you meant the value of an option ?
-
<form action="$_SERVER['PHP_SELF'] method="post"> <input type="text" name="hello" value="$_POST['hello'] /> <input type="submit" value="test" /> </form>
the above code , by pressing test (submit) button reload the page, and if user had typed anything to the field, it remains.
i can't do the same thing with select option : (and more important to me, multiple select options)
<form action="$_SERVER['PHP_SELF'] method="post"> <select name="test" > <option value="1"> 1 </option> <option value="1"> 2 </option> <option value="1"> 3 </option> </select> <input type="submit" value="test" /> </form>
the best thing i could do was :
<form action="$_SERVER['PHP_SELF'] method="post"> <select name="test" > <option value="$_POST[test]"> $_POST[test] <option> <option value="1"> 1 </option> <option value="1"> 2 </option> <option value="1"> 3 </option> </select> <input type="submit" value="test" /> </form>
this code , when the page reload , saves the users choice, but if the user click on the menu , he will saw his selected option 2 times!
the problem gets bigger, when i have about 20 options , that they can be choose multiple.
anyone help ?
-
header won't work in the middle of the html , it should be at the top . before html begins
any special code that simply opens a link automaticlly anywhere on the page ? (PHP)
It is ilogical to attempt to display data and then redirect. What is the point of displaying something if your simply going to redirect to another
that's true, i just didn't want to rearrange codes !!
-
what does output buffer exactlly do ?
-
header won't work in the middle of the html , it should be at the top . before html begins
any special code that simply opens a link automaticlly anywhere on the page ? (PHP)
for one thing the code i gave will only generate one link, if you notice im just if'ing the href portion of a single link, but now i understand what your wanting
you can do it thru javascipt on the body tag onload event.
<body onload="window.location = '<? if ($a = "hello") { echo "http://yahoo.com";} else {echo "http://gmail.com";} ?>'>
it is a good code , but if the browser do not support java, it won't work .
-
no !
the code you gave will print 2 links on the page ,then user click on them.
if want php open the links automaticlly without asking the user.
-
sorry my english bad
i mean open that link in the same window, or new window . (same window more important to me)
-
how can i tell php to run a link ?
like :
if ($a = "hello") { //goto "yahoo.com" else {//goto "gmail.com"
of course i don't mean : header(location : )
in header there should be nothing even a space before it ,
i mean just simply run a link . !
-
yea, i see the point .
i was wondering about some input texts which could record " php and mysql" statements ,coding, anything into my database, but if i leave that i guess this "codes' can work backward and against me !
-
if i set a text input, which a user can type anything to it, can it be so unsafe ?
-
now()
in MySQL Help
with now() i add to a field my computer time, how can i add GMT time ?
-
don't know if it is a mysql or php code,
i want to delete the users which hasn't activate their accounts ,
i send them through e-mail the activation link , if they do not click the link for example for 10 days, then their information in database will be deleted.
how can i apply that ?
(for the time they've signed up i've used mysql "now()" function)
-
got it ! thanks
-
it has nothing to do with safety or security or anything ?
(as session is a server-side file , no need to worry about information in it ? )
-
when a user log in :
before i show him his logged page
$_SESSION[user] = "aaa";
and at all of user pages :
if ($_SESSION[user] != "aaa") {header("location: login.php");exit;}
1.is this way enough secure ?
i mean i have put a "aaa" variable , isn't that unsafe ?
2.beside how can i use a changable variable for defining users ?
-
yea worked !
thanks
-
all done ! you really helped ! thanks !
-
how can i a page that it view for example 5 sec , then after the 5 sec it automatticly emm redirect .
i know the redirecting , so it will be how page view 5 sec , then do a action!
-
i meant add a "string" to a record,
update delete the last record and replace that with new one ,
i meant the new value go beside the old one ,
old value "i hate you john"
i add "!!!" to the field
so it will be " i hate you john!!!"
-
done ! i thought update do not delete last information , just add.
is there a command to write a value beside the record ?
for example in a table , username = john .
then i would add "1" in the right or left of john : 1john or john1 .
(i know i could get john, put in a variable then add 1 to it , any sql comand instead of 3 ,4 php lines ?)
remaining value for select :(
in PHP Coding Help
Posted
your code do not work ,!!
someone help !