PhpRay Posted May 21, 2009 Share Posted May 21, 2009 Hi !! I don't understand why this codes don't work... ( They are in the same directory...) the problem is that in the fields of the form appear the variable but in the literally way: <?=$cid?> HTML code: <html> <form method="post" action="http://localhost/open.php"> ID: <input type="text" size="10" name="id" value="<?=$cid?>"><br> NOME: <input type="text" size="10" name="nome" value="<?=$cnome?>"><br> COGNOME: <input type="text" size="10" name="cognome" value="<?=$ccognome?>"><br> EMAIL: <input type="text" size="10" name="email" value="<?=$cemail?>"><br> <input type="submit" value="Modifica"><br> </form> </html> PHP code: <?php $textfile = fopen("iscritti.txt", "r"); while ($rigafile = fgets($textfile, 1024)){ $camporiga = explode("|", $rigafile); $idriga = $camporiga[0]; if($idriga == 3){ $cid = $camporiga[0]; $cnome = $camporiga[1]; $ccognome = $camporiga[2]; $cemail = $camporiga[4]; } } fclose($textfile); ?> Where's the problem please? I chenged many times the url yet just to try !! Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/ Share on other sites More sharing options...
neogemima Posted May 21, 2009 Share Posted May 21, 2009 If I am interpreting your English correctly, you are giving the variables these values and the user submission isn't going through. I did not see the you gather the "posted" variables. Try the $variable = $_POST['name'] method and see if it passes the user input. Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838737 Share on other sites More sharing options...
PhpRay Posted May 21, 2009 Author Share Posted May 21, 2009 Sorry, I try to be more clear !! I have a little db, a flat file, called 'iscritti.txt' and I just want to take informations FROM this flat file, with my php code, and bring them into the html form... Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838739 Share on other sites More sharing options...
DarkSuperHero Posted May 21, 2009 Share Posted May 21, 2009 does the file you have your php in look like this all in one file... with file name ending in ".php" <?php $textfile = fopen("iscritti.txt", "r"); while ($rigafile = fgets($textfile, 1024)){ $camporiga = explode("|", $rigafile); $idriga = $camporiga[0]; if($idriga == 3){ $cid = $camporiga[0]; $cnome = $camporiga[1]; $ccognome = $camporiga[2]; $cemail = $camporiga[4]; } } fclose($textfile); ?> <html> <form method="post" action="http://localhost/open.php"> ID: <input type="text" size="10" name="id" value="<?=$cid?>"><br> NOME: <input type="text" size="10" name="nome" value="<?=$cnome?>"><br> COGNOME: <input type="text" size="10" name="cognome" value="<?=$ccognome?>"><br> EMAIL: <input type="text" size="10" name="email" value="<?=$cemail?>"><br> <input type="submit" value="Modifica"><br> </form> </html> also try looking into functions like, file() or file_get_contents() it might make life a bit easier... :-) http://us.php.net/manual/en/function.file.php http://us.php.net/manual/en/function.file-get-contents.php Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838747 Share on other sites More sharing options...
PhpRay Posted May 21, 2009 Author Share Posted May 21, 2009 Thanks ? I'll check !!! But I think that it should work... what's wrong in this codes? Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838764 Share on other sites More sharing options...
PhpRay Posted May 21, 2009 Author Share Posted May 21, 2009 I see now... the code is ok and the problem is in EasyPhp... it's time for xampp now !! Thanks for the links !!!! Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838849 Share on other sites More sharing options...
trq Posted May 21, 2009 Share Posted May 21, 2009 The code is not ok, your using short tags. Dont. eg; This.... EMAIL: <input type="text" size="10" name="email" value="<?=$cemail?>"><br> should be.... EMAIL: <input type="text" size="10" name="email" value="<?php echo $cemail; ?>"><br> See? Even our forum software likes it better. Besides, easyphp and xampp are not different pieces of software, just different configurations. Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838857 Share on other sites More sharing options...
PhpRay Posted May 21, 2009 Author Share Posted May 21, 2009 Thanks.. but it doesn't work.. so how can I change configuration ? I tried to click with right btn of mouse and I found the voice 'configuration' but I wasn't able to change anything there... Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838891 Share on other sites More sharing options...
trq Posted May 21, 2009 Share Posted May 21, 2009 Thanks.. but it doesn't work.. so how can I change configuration ? I tried to click with right btn of mouse and I found the voice 'configuration' but I wasn't able to change anything there... Take a look at the php.ini file. This way you'll be able to configure php within any environment not just some quick easy install. Now, define doesn't work. Obviously you have an install issue. You should post in the appropriate board. Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838905 Share on other sites More sharing options...
PhpRay Posted May 21, 2009 Author Share Posted May 21, 2009 Right... I see this is another kind of problem... I will follow all explanations !! Thanks so much for the correct code !!!! I can use this forum to check if codes are right or not... if the forum is happy it gonna color them !! lol Quote Link to comment https://forums.phpfreaks.com/topic/159047-solved-get-variables-into-a-form/#findComment-838911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.