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!
I'm trying to get a form button to execute simple PHP code that places some data into a database. (So far this works fine: if ($_POST['submitted']) { ...code...})
Once that's done I need the pop-up window to close and have the parent window refresh to display the newly inputted data.
I know i need JavaScript but no matter what i do I cant seem to get all three of these function to work in unison. Anyone have any ideas? Im fairly new to Javascript.
//first we check if the form has been submitted
---------------------------------------------------
if(isset($_POST['action'])){
//if so then we can write out some javascript for whatever reason
//connect to database and display infomation
echo "<script language='javascript'>";
echo "var name ='" . $_POST['name'] . "';";
echo "</script>";
}
else{
//if no then we write out form which will submit page to this same page
echo "<form name='form1' action='$_SERVER[PHP_SELF]' method='post>";
echo "<input type='text' name='name'/><br>";
echo "<input type='submit' value='submit' name='action'></form>";
}
}
Last edited by RobertGonzalez on Mon Jun 02, 2008 11:09 pm, edited 1 time in total.
Reason:Please use bbCode tags when posting code in the forum
PHP will do what you need it to on the server. Javascript will need to be added to the output so that when the page loads the window closes (or something akin to that).