mostafatalebi Posted November 8, 2012 Share Posted November 8, 2012 hello everybody I have made a form with several inputs and made a php script to echo a variable in the value of each input, something like this: <?php $aVariable = ""; <input name='test' value=<?php echo $aVariable ?> but what I get at the end is an input with a slash in it. I should get an empty input indeed. Quote Link to comment Share on other sites More sharing options...
trq Posted November 8, 2012 Share Posted November 8, 2012 Sorry? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted November 8, 2012 Share Posted November 8, 2012 You will need to provide a better explanation and example for us to be able to help you. The example provided is incorrect on many different levels. Quote Link to comment Share on other sites More sharing options...
mostafatalebi Posted November 8, 2012 Author Share Posted November 8, 2012 (edited) I mean I have made a form in HTML, static, and I have added several inline php script. I have set the value of the each text input to this inline script: <?php $thisInputValue = htmlentities($_Post['username'], ENT_QUOTES]; echo $thisInputValue; ?> Everything works fine, but the problem is that when i run the page for the first time, there is a "/" in the inputs. This is quite little strange, but seem to be common. my input eventually looks like this: <html> <input type="text" value="/" /> </html> Edited November 8, 2012 by mostafatalebi Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted November 8, 2012 Share Posted November 8, 2012 It should read htmlentities() instead of htmlentities(] Quote Link to comment Share on other sites More sharing options...
mostafatalebi Posted November 8, 2012 Author Share Posted November 8, 2012 take it as a mistype for replying. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 8, 2012 Share Posted November 8, 2012 Could you show more of the code? It would be helpful to see how the PHP code modifies the HTML form. Quote Link to comment Share on other sites More sharing options...
mostafatalebi Posted November 8, 2012 Author Share Posted November 8, 2012 (edited) <form action="" method="post" name="register_form"> <label for="first_name"> First Name </label> <input type="text" name="first_name" class="inputs" value=<?php echo $input['firstname']; ?>/> <?php // get the value of the variables if($error['firstname_alert'] != "") { echo "<div id='required'>" . $error['firstname_alert'] . "</div>"; } ?> <br /><br /> This is a part of the script. The rest is the duplication of this part and making other inputs. so this showa you almost the entire stracture of my register_view.php. this file then is included in another register.php file and is shown. EVERYTHING works fine but the only problem is the forward slash added to the input. Also here is the variables for all of my PHP scripts: $error;// now the elements $error['register_alert'] = ""; $error['firstname_alert'] = " "; $error['lastname_alert'] = ""; $error['password_alert'] = ""; $error['password2_alert'] = ""; $error['email_alert'] = ""; // all the elements for erroring while registration $input; $input['firstname'] = ""; $input['lastname'] = ""; $input['password'] = ""; $input['password2'] = ""; $input['email'] = ""; $input['information'] = ""; // all the elements for Edited November 8, 2012 by mostafatalebi Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 8, 2012 Share Posted November 8, 2012 Adding quotes around the value attribute's value should get rid of the issue. <input type="text" name="first_name" class="inputs" value="<?php echo $input['firstname']; ?>" /> Also note that the <label> tag isn't really doing anything. You need to add an id attribute to the <input> tag. <input type="text" name="first_name" id="first_name" class="inputs" value="<?php echo $input['firstname']; ?>" /> Now clicking the label should put focus into the first_name field. Quote Link to comment Share on other sites More sharing options...
mostafatalebi Posted November 8, 2012 Author Share Posted November 8, 2012 Hey man thank you very much. I searched the whole net and found nothing. Thanks a million, again. problem is solved by your solution Quote Link to comment 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.