hi, I am having serious trouble with my PHP Postcard script. The error message i get is:
Notice: Undefined index:
Notice: Undefined variable
Basically it does not send out the scripts at all. It is hosted on Awardspace. -
<?php
-
-
session_start();
-
//check error log
-
ini_set('display_errors', 1);
-
ini_set('log_errors', 1);
-
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
-
error_reporting(E_ALL);
-
-
// CHANGE PARAMETERS HERE BEGIN
-
$senderName = " Holidays From Home "; // Eg.: John's Postcards
-
$senderEmail = "chris01@voluntary.awardspace.co.uk"; // Eg.: john@postcard.com
-
// Change only if you have problems with urls
-
$postcardURL = "http://".$_SERVER[""].$_SERVER[""]; //problem is definetely here!!!
-
// CHANGE PARAMETERS HERE END
-
$result = 0;
-
$msg = "";
-
$msg1 = "";
-
$pic = "";
-
function displayPhotos()
-
{
-
global $pic;
-
$columns = 5;
-
$act = 0;
-
$act1 = 0;
-
// Open the actual directory
-
if($handle = opendir("thumbs"))
-
{
-
// Read all file from the actual directory
-
while($file = readdir($handle))
-
{
-
if(!is_dir($file))
-
{
-
if(isset($pic[1]))
-
{
-
if($pic[1] == $act1){$sel = "checked";}
-
else{$sel = "unchecked";}
-
}
-
if($act == 0){echo "<tr>";}
-
echo "<td align='center'><img src='thumbs/$file' alt='postcard'/><br/><input type='radio' name='selimg' value='$file,$act1' $sel/></td>";
-
$act++;
-
$act1++;
-
if($act == $columns){$act = 0;echo "</tr>";}
-
-
}
-
}
-
echo "</tr>";
-
}
-
}
-
?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
-
<html>
-
<head>
-
<title>Micro Postcard</title>
-
<link href= "style/style.css" rel="stylesheet" type="text/css" />
-
</head>
-
<body>
-
<div id="main">
-
<div class="style1" id="caption">
-
<div align="left" class="style1"></div>
-
</div>
-
<?php //makes sure form is correctly filled in
-
if(!empty($_POST["submit"]))
-
{
-
if(empty($_POST["selimg"])){$msg = "Please select an image from above!";$result = 3;}
-
else{$pic = explode(",",$_POST["selimg"]);}
-
if(empty($_POST["email"]) && empty($result)){$msg1 = "You must enter an email address!";$result = 3;}
-
$secCode = empty($_POST["secCode"]) ? "" : strtolower($_POST["secCode"]);
-
if($secCode == $_SESSION["securityCode"] && $result != 3)
-
{
-
$filename = date("YmdGis");
-
$f = fopen("messages/".$filename.".txt","w+");
-
fwrite($f,$pic[0]."\n");
-
fwrite($f,$_POST['email']."\n");
-
fwrite($f,stripslashes($_POST["message"])."\n");
-
fclose($f);
-
// Compose the mail
-
$from = "From: $senderName <$senderEmail>\r\n";
-
$replay = "Reply-To: $senderEmail\r\n";
-
$params = "MIME-Version: 1.0\r\n";
-
$params .= "Content-type: text/plain; charset=iso-8859-1\r\n";
-
$mailtext = "You have just received a Virtual Postcard!\r\n\r\n
-
You can pick up your postcard at the following web address:\r\n
-
$postcardURL?show=$filename\r\n\r\n
-
We hope you enjoy your postcard, and if you do, please take a moment to send a few yourself!\r\n\r\n
-
Regards,\r\n
-
Holidays From Home\r\n
-
$postcardURL";
-
// Send email
-
@mail($_POST["email"],"You've received a postcard",$mailtext,$from.$replay.$params);
-
echo "<center>
-
Your postcard was sent successfully!<br /><br />
-
<img src='images/$pic[0]' alt='postcard' /><br /><br /><br />".stripslashes($_POST["message"]).
-
"</center>";
-
$result = 1;
-
}
-
else{if($result != 3){$result = 2;}}
-
}
-
if(!empty($_GET["show"]))
-
{
-
$file = $_GET["show"];
-
$content = file("messages/$file.txt");
-
$pic = $content[0];
-
unset($content[0]);
-
unset($content[1]);
-
foreach($content as $value){$main .= $value;}
-
echo "<center>
-
Your postcard!<br /><br />
-
<img src='images/$pic' alt='postcard' /><br /><br /><br />$main
-
</center>";
-
}
-
if((empty($result) || $result == 2 || $result == 3) && empty($_GET["show"]))
-
{
-
echo "<form action='#' method='post'>
-
<table align='center'>";
-
displayPhotos();
-
echo "</table>
-
<div style='color:#f00;font-size:16px;'>$msg</div>
-
<h2>Fill in the Form and then click on Send Card!!</h2>
-
<table width='100%'>
-
<tr><td>Send to (email address):</td><td><div style='color:#f00;font-size:16px;'>$msg1</div><input type='text' name='email' size='30' value='".$_POST["email"]."' /></td></tr>
-
<tr><td>Message:</td><td><textarea name='message' rows='10' cols='40'>".stripslashes($_POST["message"])."</textarea></td></tr>
-
<tr><td colspan='2'>".($result == 2 ? "<p style='color:#f00;font-size:16px;'>Sorry the security code is invalid! Please try it again!</span></p>" : " ")."</tr>
-
<tr>
-
<td>Security code: <input class='text' name='secCode' type='text' size='10' />
-
</td><td><img src='securityCode.php' alt='security code' border='1' /></td>
-
</tr>
-
<tr><td colspan='2'> </tr>
-
<tr><td colspan='2' align='left'><input type='submit' value='Send card!' name='submit'/></td></tr>
-
</table>
-
</form>";
-
}
-
?>
-
Any help would be much appreciated
2 3754 JKing 1,206
Recognized Expert Top Contributor -
$postcardURL = "http://".$_SERVER[""].$_SERVER[""]; //problem is definetely here!!!
-
$_SERVER is an array of variables. You are using a blank index which results in the undefined index and variable.
It should look something like $_SERVER['SERVER_NAME'] but without knowing where you want to send the users I cannot direct you much further.
Here is some more info on the $_SERVER variable PHP $_SERVER Sign in to post your reply or Sign up for a free account.
Similar topics |
by: news.bigpond.com |
last post by:
getting errors
Notice: Undefined index: name in F:\uni\Software
engineering\assignment4\guestbook.php on line 6
the variable $name is declared as $name = _POST;
What could be causing this?
I've recently installed php 5 on IIS with mysql 4. All running on windows XP
|
by: John Oliver |
last post by:
PHP Notice: Undefined index: name in
/home/www/reformcagunlaws.com/new.php on line 6
PHP Notice: Undefined index: address in
/home/www/reformcagunlaws.com/new.php on line 7
PHP Notice: Undefined index: city in
/home/www/reformcagunlaws.com/new.php on line 8
PHP Notice: Undefined index: county in
/home/www/reformcagunlaws.com/new.php on line 9
PHP Notice: Undefined index: zip in
/home/www/reformcagunlaws.com/new.php on line...
|
by: Craig Morrison |
last post by:
I'm getting this:
PHP Notice: Undefined index: D1 in
/var/www/html.....
From this line of code:
$id_option = $_POST;
Which is posted by this:
|
by: cassbiz |
last post by:
Here are the errors that are coming up in my error_log
Notice: Undefined index: andatum in /zipcode.php on line 11
Notice: Undefined index: andatum in /zipcode.php on line 12
Notice: Undefined index: abdatum in /zipcode.php on line 13
Notice: Undefined index: zimmer in /zipcode.php on line 14
Notice: Undefined index: city in /zipcode.php on line 39
Notice: Undefined index: state in /zipcode.php on line 41
|
by: number1yan |
last post by:
Can anyone help me,
i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is:
Notice: Undefined index: FriendName in D:\Yan\Over_8\SendEmail.php on line 4, Notice: Undefined index: FriendEmail in D:\Yan\Over_8\SendEmail.php on line 5, Notice: Undefined index: Name in D:\Yan\Over_8\SendEmail.php on line 6, Notice: Undefined index: Email...
| |
by: iera |
last post by:
i've got this message
Notice: Undefined index: name in c:\program files\easyphp1-8\www\forum\kemaskini.php on line 2
i've used this coding..
<?php
$name = $_POST;
$date = $_POST;
$time = $_POST;
|
by: bill |
last post by:
I am trying to write clean code but keep having trouble deciding
when to quote an array index and when not to.
sometimes when I quote an array index inside of double quotes I
get an error about enased whitespace (to my best memory)
AT other times I get an undefined index notice as below:
Notice: Undefined index: last_reminder_id in...
|
by: siyaverma |
last post by:
Hi,
I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that,
After doing some changes when i run it on my local server it was working fine but giving some errors those are
Notice: Undefined index: phplogin in C:\Inetpub\wwwroot\sampleft\index.php on line 116
Notice: Undefined variable: username in C:\Inetpub\wwwroot\sampleft\index.php on line 116
...
|
by: movieking81 |
last post by:
Another PHP newbie here, I trolled the boards here trying some of the different solutions but I keep getting the errors over an over. maybe my problem is specific. I keep getting the following when I load my test.php file into the browser.
PHP Notice: Undefined index: variable in Path to page on line 24
The line in question is this
$query1="insert into tablename ('var','var1','var2','var3','var4','var5','var6') values ('" ....
|
by: cyberlei |
last post by:
hi all,
I`m getting this error
Notice: Undefined index: user in c:\inetpub\wwwroot\login.php on line 96
Notice: Undefined variable: message in c:\inetpub\wwwroot\login.php on line 101
Could someone please tell me where I did wrong? Here is the Code, Thanks a lot
<?php
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |