NathanS Posted April 26, 2008 Share Posted April 26, 2008 Hi guys, Having an issue, first time using php self to submit a form - however, am getting: PHP Notice: Undefined index: cover in tform.php on line 2 PHP Notice: Undefined variable: PHP_SELF intform.php on line 11 When loading up the following page: <?php $cover = $_POST["cover"]; if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <html> <head> <title>Cover Question</title> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> Do you require cover for less than 28 days? <select name="cover"> <option value="yes">Yes</option> <option value="no">No</option> <input type="submit" value="submit" name="submit"> </form> <? } else { if ($cover =="yes") { header('Location: http://www.adrianflux.co.uk/'); } header('Location: https://www.hertsinsurance.com/epa.php'); } ?> Any ideas? Thanks! Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 26, 2008 Share Posted April 26, 2008 <?php if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <html> <head> <title>Cover Question</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Do you require cover for less than 28 days? <select name="cover"> <option value="yes">Yes</option> <option value="no">No</option> <input type="submit" value="submit" name="submit"> </form> <?php } else { if (isset($_POST['cover'])){ $cover = $_POST["cover"]; if ($cover =="yes") { header('Location: http://www.adrianflux.co.uk/'); } header('Location: https://www.hertsinsurance.com/epa.php'); } } ?> Quote Link to comment Share on other sites More sharing options...
NathanS Posted April 26, 2008 Author Share Posted April 26, 2008 Yep, also should've probably checked my php.ini for register_globals! Thanks 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.