hello,
I have an input and a submit button in my first page.
when I write a word in the input box and push the button, it finds the meaning of the word from mysql DB and show it to my page,but for the first time when the input box is empty and I did not push the button first, what code I should write to prevent of any process before pushing the button?
thanks
Let’s assume your submit button name is “submit” (<input type=‘submit’ name=‘submit’ … />),
[php]
if (isset($_POST[‘submit’])) {
/* Commands which are written here will execute only if user pressed on submit button. */
}
[/php]
This is my code.line 18 has error.because for the first time there is nothing in the box to compare to data in Database.
<?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("user", $con); $result = mysql_query("SELECT * FROM Dictionary WHERE EWord='$_POST[word]'"); echo "Word | Meaning |
---|---|
" . $row['EWord'] . " | "; echo "" . $row['Definition'] . " | "; echo "
I found it:)
if(!empty($_POST[‘Feild’])) is what I had to write.
Thanks