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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.