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! Link to comment https://forums.phpfreaks.com/topic/103001-solved-php-self-issue/ 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'); } } ?> Link to comment https://forums.phpfreaks.com/topic/103001-solved-php-self-issue/#findComment-527638 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 Link to comment https://forums.phpfreaks.com/topic/103001-solved-php-self-issue/#findComment-527639 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.