Jump to content

[SOLVED] php self issue


NathanS

Recommended Posts

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

<?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');
}
}
?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.