collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 506
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: Errors from form in php block  (Read 3922 times)

0 Members and 1 Guest are viewing this topic.

Offline willemjan

  • Semi Newbie
  • *
  • Posts: 41
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Errors from form in php block
« on: December 09, 2010, 07:46:18 AM »
Hello community.

My errorlog filles up with this kind of errors:

Code: [Select]
http://www.hervormddamwald.nl/index.php?page=contact
8: Undefined index: bericht
Bestand: /public/sites/www.hervormddamwald.nl/Sources/Subs-Portal.php(1174) : eval()'d code
Regel: 67

On that page I have setup an contact form. I think that causes the problem... If you need that code, I can get you that.

In a few weeks I get hundreds of these errors... Do you have an clue on what it could be?
« Last Edit: December 09, 2010, 10:51:47 AM by AngelinaBelle »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Errors in error log
« Reply #1 on: December 09, 2010, 10:04:58 AM »
I agree -- it sounds as though you have created a custom php page and made an error.
You have tried to use an array element 'bericht' without creating that array element first.
This should be pretty easy to track down -- the syntax is
Code: [Select]
$arrayName['bericht']And the problem occurs on line 67 of the contents of your php page.
 
IF you are having trouble spotting it, feel free to post the code here.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline willemjan

  • Semi Newbie
  • *
  • Posts: 41
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Errors in error log
« Reply #2 on: December 09, 2010, 10:20:26 AM »
Ok, I'll try and track it down. This error actually happens on more then one array element. What should my action be?

Offline willemjan

  • Semi Newbie
  • *
  • Posts: 41
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Errors in error log
« Reply #3 on: December 09, 2010, 10:23:17 AM »
Could it be this:

Code: [Select]
      <label for="bericht">Bericht:</label><br />
      <textarea id="bericht" name="bericht" rows="8" style="width: 400px;">' .
      htmlspecialchars($_POST['bericht']) . '</textarea><br />

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Errors in error log
« Reply #4 on: December 09, 2010, 10:42:54 AM »
That might be it. You should first check if $_POST['bericht] exists.
 
http://www.w3schools.com/php/php_post.asp
http://www.php.net/docs.php
 
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline willemjan

  • Semi Newbie
  • *
  • Posts: 41
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Errors in error log
« Reply #5 on: December 09, 2010, 10:46:08 AM »
I think I'll better post the complete script. I'm actually not good at this....

Code: [Select]
<?php
session_start
(); // zorg ervoor dat session_start ALTIJD bovenaan ALLES van je pagina staat, anders werkt het niet!
 
/*******************************
*        CONTACT FORMULIER                     *
*        contactformulier.php             *
*                                                             *
*        Author: Miranda Verburg         *
*        Datum: 10 september 2010     *
*                                                             *
*        Pas het e-mail adres aan     *
*        bij $mail_ontv en upload   *
*        het naar je webserver..         *
********************************/

// E-mailadres van de ontvanger
$mail_ontv 'my@email.com'// <<<----- voer jouw e-mailadres hier in!

// Speciale checks voor naam en e-mailadres
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    
// naam controle
    
if (!ereg('^[ a-zA-Z-]+$'$_POST['naam']))
        
$naam_fout 1;
    
// e-mail controle
    
if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL))
            
$email_fout 1;
    
// antiflood controle
    
if (!empty($_SESSION['antiflood']))
    {
        
$seconde 20// 20 seconden voordat dezelfde persoon nog een keer een e-mail mag versturen
        
$tijd time() - $_SESSION['antiflood'];
        if(
$tijd $seconde)
            
$antiflood 1;
    }
}

// Kijk of alle velden zijn ingevuld - naam mag alleen uit letters bestaan en het e-mailadres moet juist zijn
if (($_SERVER['REQUEST_METHOD'] == 'POST' && (!empty($antiflood) || empty($_POST['naam']) || !empty($naam_fout) || empty($_POST['mail']) || !empty($email_fout) || empty($_POST['bericht']) || empty($_POST['onderwerp']))) || $_SERVER['REQUEST_METHOD'] == 'GET')
{
    if (
$_SERVER['REQUEST_METHOD'] == 'POST')
    {
        if (!empty(
$naam_fout))
            echo 
'<p>Uw naam mag alleen letters bevatten.</p>';
        elseif (!empty(
$email_fout))
            echo 
'<p>Uw e-mailadres is niet juist.</p>';
        elseif (!empty(
$antiflood))
            echo 
'<p>U mag slechts &eacute;&eacute;n bericht per ' $seconde ' seconde versturen.</p>';
        else
            echo 
'<p>U bent uw naam, e-mailadres, onderwerp of bericht vergeten in te vullen.</p>';
    }
        
  
// HTML e-mail formlier
  
echo '<form method="post" action="' $_SERVER['REQUEST_URI'] . '" />
  <p>
  
      <label for="naam">Naam:</label><br />
      <input type="text" id="naam" name="naam" value="' 
htmlspecialchars($_POST['naam']) . '" /><br />
      
      <label for="mail">E-mailadres:</label><br />
      <input type="text" id="mail" name="mail" value="' 
htmlspecialchars($_POST['mail']) . '" /><br />
      
      <label for="onderwerp">Onderwerp:</label><br />
      <input type="text" id="onderwerp" name="onderwerp" value="' 
htmlspecialchars($_POST['onderwerp']) . '" /><br />
      
      <label for="bericht">Bericht:</label><br />
      <textarea id="bericht" name="bericht" rows="8" style="width: 400px;">' 
htmlspecialchars($_POST['bericht']) . '</textarea><br />
      
      <input type="submit" name="submit" value=" Versturen " />
  </p>
  </form>'
;
}
// versturen naar
else
{      
  
// set datum
  
$datum date('d/m/Y H:i:s');
    
  
$inhoud_mail "===================================================\n";
  
$inhoud_mail .= "Ingevulde contact formulier " $_SERVER['HTTP_HOST'] . "\n";
  
$inhoud_mail .= "===================================================\n\n";
  
  
$inhoud_mail .= "Naam: " htmlspecialchars($_POST['naam']) . "\n";
  
$inhoud_mail .= "E-mail adres: " htmlspecialchars($_POST['mail']) . "\n";
  
$inhoud_mail .= "Bericht:\n";
  
$inhoud_mail .= htmlspecialchars($_POST['bericht']) . "\n\n";
    
  
$inhoud_mail .= "Verstuurd op " $datum " via het IP adres " $_SERVER['REMOTE_ADDR'] . "\n\n";
    
  
$inhoud_mail .= "===================================================\n\n";
  
  
// --------------------
  // spambot protectie
  // ------
  // van de tutorial: http://www.phphulp.nl/php/tutorial/beveiliging/spam-vrije-contact-formulieren/340/
  // ------
  
  
$headers 'From: ' htmlspecialchars($_POST['naam']) . ' <' $_POST['mail'] . '>';
  
  
$headers stripslashes($headers);
  
$headers str_replace('\n'''$headers); // Verwijder \n
  
$headers str_replace('\r'''$headers); // Verwijder \r
  
$headers str_replace("\"""\\\""str_replace("\\""\\\\"$headers)); // Slashes van quotes
  
  
$_POST['onderwerp'] = str_replace('\n'''$_POST['onderwerp']); // Verwijder \n
  
$_POST['onderwerp'] = str_replace('\r'''$_POST['onderwerp']); // Verwijder \r
  
$_POST['onderwerp'] = str_replace("\"""\\\""str_replace("\\""\\\\"$_POST['onderwerp'])); // Slashes van quotes
  
  
if (mail($mail_ontv$_POST['onderwerp'], $inhoud_mail$headers))
  {
      
// zorg ervoor dat dezelfde persoon niet kan spammen
      
$_SESSION['antiflood'] = time();
      
      echo 
'<h1>Het contactformulier is verzonden</h1>
      
      <p>Bedankt voor het invullen van het contactformulier. We zullen zo spoedig mogelijk contact met u opnemen.</p>'
;
  }
  else
  {
      echo 
'<h1>Het contactformulier is niet verzonden</h1>
      
      <p><b>Onze excuses.</b> Het contactformulier kon niet verzonden worden.</p>'
;
  }
}
?>


Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Errors in error log
« Reply #6 on: December 09, 2010, 10:49:00 AM »
That part of the code is expected to be executed even if that value is empty
if 
(
 ($_SERVER['REQUEST_METHOD'] == 'POST' &&
  (
   !empty($antiflood) || empty($_POST['naam'])
   || !empty($naam_fout) || empty($_POST['mail'])
   || !empty($email_fout) || empty($_POST['bericht'])
   || empty($_POST['onderwerp'])
  )
 )
 || $_SERVER['REQUEST_METHOD'] == 'GET'
)

So I would think the code would be prepared for it to be unset.
 
Code: (find) [Select]
htmlspecialchars($_POST['bericht'])
Code: (replace) [Select]
( empty($_POST['bericht']) ? '' :  htmlspecialchars($_POST['bericht']) )
And so on for the other values that just might be empty.
 
HOWEVER:  If this code did not give the original author any problems, then it is probably expecting something different from what it is getting. It seems to expect that value to be set, even if it is completely blank.  You may be using this form differently than it was intended to be used, and so you might run into other problems, as well.
 
It might be a good idea to contact the author.
« Last Edit: December 09, 2010, 11:08:43 AM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline willemjan

  • Semi Newbie
  • *
  • Posts: 41
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Errors in error log
« Reply #7 on: December 10, 2010, 02:30:18 AM »
Quote
Code: (find) [Select]
htmlspecialchars($_POST['bericht'])
Code: (replace) [Select]
( empty($_POST['bericht']) ? '' :  htmlspecialchars($_POST['bericht']) )
This actually worked. I did this for all of the errors, and they are gone now. I emptied my errorlog and tried a few times. The mail also gets sent. I also deleted the sessionstart out of the script. That caused errors two...

I actually don't understand why it works, but it does.

Thanks allot for your help!!  :D

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Errors from form in php block
« Reply #8 on: December 10, 2010, 07:10:45 AM »
Yes -- session_start should not be necessary, as SMF starts the session itself.
 
http://php.net
http://w3schools.com/php
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?