other php script on page, session_start();

5 posts by 3 authors in: Forums > CMS Builder
Last Post: February 18, 2010   (RSS)

By rez - February 17, 2010 - edited: February 17, 2010

I have a contact form I'm using that requires this at the top of the page and works fine without CMSB code at the top:

<?php
session_start();
require_once('config.php');
?>


The config file is very simple, containing the e-mail addresses. All the other code for the contact form is in the body of the page.

The CMSB page works separately as well. Its when I try to put the form onto a working CMSB page that I have errors.

Where exactly do I put the above code? With or without its onw php tags? Everything I tried gave variable errors and others for the contact form.

Re: [Djulia] other php script on page, session_start();

By rez - February 17, 2010

There is captcha on the page. Niether solution worked for me, if I'm using it right. I tried the script above and below the CMSB code and also tried:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
require_once "/example/public_html/cmsAdmin/lib/viewer_functions.php";


list($social_media_linksRecords, $social_media_linksMetaData) = getRecords(array(
'tableName' => 'social_media_links',
));
session_write_close ();

session_name ("security_code");
session_start ();
require_once('config.php');

?>


But no luck.


here is the beginning of the script on the page:
<?
if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
unset($_SESSION['security_code']);
} else {
$error_array[] .= "The security code you have entered is incorrect.";
}

Re: [rez] other php script on page, session_start();

By Djulia - February 18, 2010

You tested without using the captcha?

If not, you can indicate the error message?

Djulia

Re: [Djulia] other php script on page, session_start();

By Chris - February 18, 2010

Hi rez,

What error messages are you getting? Can you post the full PHP source code of both your contact form and config.php?

On a hunch, this line looks wrong to me:

$error_array[] .= "The security code you have entered is incorrect.";

"[] =" means add new array element, while ".=" means append this string to an existing variable. I don't think it makes sense to append a string to an array element that doesn't exist yet.
All the best,
Chris