This is a discussion on "session_start error" within the PHP Forum section. This forum, and the thread "session_start error are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
session_start error
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
session_start error
when I test this script I get the following error -
"Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /hsphere/local/home/icmwebs/inkukustop.co.za/form.php:3) in /hsphere/local/home/icmwebs/inkukustop.co.za/form.php on line 3" I have checked for extra spaces and made sure the php is before the html tag. Here is the script: <body bgcolor="yellow"> <div align="center"> <?php session_start(); if( isset($_POST['submit'])) { if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. echo 'Thank you. Your message said "'.$_POST['message'].'"'; unset($_SESSION['security_code']); } else { // Insert your code for showing an error message here echo 'Sorry, you have provided an invalid security code'; } } else { ?> <form action="form.php" method="post"> <label for="name">Name: </label><input type="text" name="name" id="name"><br> <label for="email">Email: </label><input type="text" name="email" id="email"><br> <label for="message">Message: </label><textarea rows="5" cols="30" name="message" id="message"></textarea><br> <img src="CaptchaSecurityImages.php?width=100&height=40 &characters=5"><br> <label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text"><br> <input type="submit" name="submit" value="Submit"> </form><?php } ?></div> </body> any ideas please? |
|
|
|
#2
|
||||
|
||||
|
Re: session_start error
have a look here: http://forum.mamboserver.com/archive...p/t-42814.html
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#3
|
|||
|
|||
|
Re: session_start error
The session start must be the very first thing on the page because it is part of the header. When you output something onto the page the headers will have been sent and a session cannot be started.
So you should do this to make it work:
|
|
#4
|
|||
|
|||
|
Re: session_start error
Thanks guys!
Webforumz rocks. No be-littling attitude to newbies like me and fast, accurate solutions. |
|
#5
|
|||
|
|||
|
Re: session_start error
No problem.
We aim to please |
|
#6
|
||||
|
||||
|
Re: session_start error
That alone should be the new testimonal on the front page
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#7
|
|||
|
|||
|
Re: session_start error
Oooh! a testimonial on the front page...my 15 seconds of fame...
Your solutions worked a treat but I am having trouble getting the message field to appear in the email reply. I just get the email address and the name. here is the amended code: <?php session_start(); if( isset($_POST['submit'])) { if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { mail( "emotion@inspire.net.nz", "Website Feedback", $name, $email, $message ); echo 'Thank you for your enquiry. Will contact you shortly'; unset($_SESSION['security_code']); } else { // Insert your code for showing an error message here echo 'Sorry, you have provided an invalid security code'; } } else { ?> <form action="form.php" method="post"> <label for="name">Name: </label><input type="text" name="name" id="name"><br> <label for="email">Email: </label><input type="text" name="email" id="email"><br> <label for="message">Message: </label><textarea rows="5" cols="30" name="message" id="message"></textarea><br> <img src="CaptchaSecurityImages.php?width=100&height=40 &characters=5"><br> <label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text"><br> <input type="submit" name="submit" value="Submit"> </form> <?php } ?> Additionally, is it possible to add a background color and css styling to the echo messages? |
|
#8
|
|||
|
|||
|
Re: session_start error
I don't know where the $name, $email, and $message variables get set, but like this is should work:
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Getting the "Microsoft JET Database Engine error '80040e14'" error. | VegaLA | Classic ASP | 3 | Jan 26th, 2008 00:12 |
| Keep getting error message Microsoft VBScript runtime error '800a01a8' | cpando1974 | Classic ASP | 2 | Aug 7th, 2007 12:00 |
| session_start(); AHHH! | Bradster | PHP Forum | 3 | Jun 2nd, 2007 11:31 |
| Error 500 - Internal server error | JasonStanley | PHP Forum | 3 | Apr 23rd, 2007 17:56 |