473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Postcard Notice: Undefined index: Notice: Undefined variable errors

2 New Member
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.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. session_start();
  4. //check error log
  5. ini_set('display_errors', 1);
  6. ini_set('log_errors', 1);
  7. ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
  8. error_reporting(E_ALL);
  9.  
  10. // CHANGE PARAMETERS HERE BEGIN
  11. $senderName  = " Holidays From Home "; // Eg.: John's Postcards
  12. $senderEmail = "chris01@voluntary.awardspace.co.uk";  // Eg.: john@postcard.com
  13. // Change only if you have problems with urls
  14. $postcardURL = "http://".$_SERVER[""].$_SERVER[""]; //problem is definetely here!!!
  15. // CHANGE PARAMETERS HERE END
  16. $result = 0;
  17. $msg = "";
  18. $msg1 = "";
  19. $pic = "";
  20. function displayPhotos()
  21. {
  22.  global $pic;
  23.  $columns = 5;
  24.  $act = 0;
  25.  $act1 = 0;
  26.  // Open the actual directory
  27.  if($handle = opendir("thumbs"))
  28.  {
  29.   // Read all file from the actual directory
  30.   while($file = readdir($handle))
  31.   {
  32.    if(!is_dir($file))
  33.    {
  34.     if(isset($pic[1]))
  35.     {
  36.      if($pic[1] == $act1){$sel = "checked";}
  37.      else{$sel = "unchecked";}
  38.      }
  39.     if($act == 0){echo "<tr>";}
  40.     echo "<td align='center'><img src='thumbs/$file' alt='postcard'/><br/><input type='radio' name='selimg' value='$file,$act1' $sel/></td>";
  41.     $act++;
  42.     $act1++;
  43.     if($act == $columns){$act = 0;echo "</tr>";}
  44.  
  45.        }
  46.     }
  47.   echo "</tr>";
  48.   }    
  49.  }
  50. ?>
  51. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
  52. <html>
  53. <head>
  54.  <title>Micro Postcard</title>
  55.  <link href= "style/style.css" rel="stylesheet" type="text/css" />
  56. </head>
  57. <body>
  58. <div id="main">
  59. <div class="style1" id="caption">
  60. <div align="left" class="style1"></div>
  61. </div>
  62.    <?php //makes sure form is correctly filled in 
  63.  if(!empty($_POST["submit"]))
  64.  {
  65.   if(empty($_POST["selimg"])){$msg = "Please select an image from above!";$result = 3;}
  66.   else{$pic = explode(",",$_POST["selimg"]);}
  67.   if(empty($_POST["email"]) && empty($result)){$msg1 = "You must enter an email address!";$result = 3;}
  68.   $secCode = empty($_POST["secCode"]) ? "" : strtolower($_POST["secCode"]);
  69.   if($secCode == $_SESSION["securityCode"] && $result != 3)
  70.   {
  71.    $filename = date("YmdGis");
  72.    $f = fopen("messages/".$filename.".txt","w+");
  73.    fwrite($f,$pic[0]."\n");
  74.    fwrite($f,$_POST['email']."\n");
  75.    fwrite($f,stripslashes($_POST["message"])."\n");
  76.    fclose($f);
  77.    // Compose the mail
  78.    $from = "From: $senderName <$senderEmail>\r\n";
  79.    $replay = "Reply-To: $senderEmail\r\n";    
  80.    $params = "MIME-Version: 1.0\r\n";
  81.    $params .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  82.    $mailtext = "You have just received a Virtual Postcard!\r\n\r\n
  83.                 You can pick up your postcard at the following web address:\r\n
  84.                 $postcardURL?show=$filename\r\n\r\n
  85.                 We hope you enjoy your postcard, and if you do, please take a moment to send a few yourself!\r\n\r\n
  86.                 Regards,\r\n
  87.                 Holidays From Home\r\n
  88.                 $postcardURL";
  89.    // Send email
  90.    @mail($_POST["email"],"You've received a postcard",$mailtext,$from.$replay.$params);
  91.    echo "<center>
  92.           Your postcard was sent successfully!<br /><br />
  93.           <img src='images/$pic[0]' alt='postcard' /><br /><br /><br />".stripslashes($_POST["message"]).
  94.         "</center>";
  95.    $result = 1;
  96.    }
  97.   else{if($result != 3){$result = 2;}}
  98.   }
  99.  if(!empty($_GET["show"]))
  100.  {
  101.   $file = $_GET["show"];
  102.   $content = file("messages/$file.txt");
  103.   $pic = $content[0];
  104.   unset($content[0]);
  105.   unset($content[1]);
  106.   foreach($content as $value){$main .= $value;}
  107.   echo "<center>
  108.          Your postcard!<br /><br />
  109.          <img src='images/$pic' alt='postcard' /><br /><br /><br />$main
  110.         </center>";
  111.   }
  112.  if((empty($result) || $result == 2 || $result == 3) && empty($_GET["show"]))
  113.  {
  114.   echo "<form action='#' method='post'>
  115.          <table align='center'>";
  116.          displayPhotos();
  117.   echo  "</table>
  118.          <div style='color:#f00;font-size:16px;'>$msg</div>        
  119.          <h2>Fill in the Form and then click on Send Card!!</h2>
  120.          <table width='100%'>
  121.           <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>
  122.           <tr><td>Message:</td><td><textarea name='message' rows='10' cols='40'>".stripslashes($_POST["message"])."</textarea></td></tr>
  123.           <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>" : "&nbsp;")."</tr>
  124.           <tr>
  125.            <td>Security code: <input class='text' name='secCode' type='text' size='10' />
  126.            </td><td><img src='securityCode.php' alt='security code' border='1' /></td>
  127.           </tr>
  128.           <tr><td colspan='2'>&nbsp;</tr>
  129.           <tr><td colspan='2' align='left'><input type='submit' value='Send card!' name='submit'/></td></tr>
  130.          </table>
  131.         </form>";
  132.   }
  133. ?>
  134.  
Any help would be much appreciated
Aug 18 '10 #1
2 3754
JKing
1,206 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. $postcardURL = "http://".$_SERVER[""].$_SERVER[""]; //problem is definetely here!!!
  2.  
$_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 variablePHP $_SERVER
Aug 18 '10 #2
norwichchris
2 New Member
Here is the URL script. IT is supposed to send an email with a hyperlink and then the reciepient can opne the link to view the card.

see link below:
http://voluntary.awardspace.co.uk/Postcard.php

Thx!
Aug 20 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
10886
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
4
7179
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...
26
3739
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:
3
4960
cassbiz
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
3
5492
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...
4
5256
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;
15
4461
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...
5
7178
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 ...
5
6682
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 ('" ....
4
4076
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
0
8324
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,...
0
8842
Oralloy
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...
0
8617
tracyyun
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...
0
7352
agi2029
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...
1
6176
isladogs
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...
0
4173
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...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
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
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.