echo $_SERVER['PHP_SELF'];

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
ronanski
New Member
New Member
Posts: 7
Joined: Tue Feb 08, 2011 9:09 pm

echo $_SERVER['PHP_SELF'];

Post by ronanski »

Hi all,

CMS Made Simple 1.7 "Cape Verde"
Apache version 2.2.17
PHP version 5.2.15

I have a contact form on a page that is validating and sending an email ok. However on clicking submit the user is directed to the site route instead of to the contact page with the successful submission html displayed. I'm using echo $_SERVER['PHP_SELF']; Does anyone know why the page is redirectiong to the homepage? Many thanks.

Code: Select all

{php} if(isset($hasError)) { //If errors are found {/php}
		<p class="error">Please check if you've filled all the fields with valid information. Thank you.</p>
	{php} } {/php}

	{php} if(isset($emailSent) && $emailSent == true) { //If email is sent {/php}
		<p><strong>Email Successfully Sent!</strong></p>
		<p>Thank you <strong>{php} echo $name;{/php}</strong> for using my contact form! Your email was successfully sent and I will be in touch with you soon.</p>
	{php} } {/php}

	<form method="post" action="{php} echo $_SERVER['PHP_SELF']; {/php} " id="contactform">
		<div>
		    <label for="name"><strong>Name:</strong></label>
			<input type="text" size="40" name="contactname" id="contactname" value="" class="required" />
		</div>

		<div>
			<label for="email"><strong>Email:</strong></label>
			<input type="text" size="40" name="email" id="email" value="" class="required email" />
		</div>

		<div>
			<label for="subject"><strong>Subject:</strong></label>
			<input type="text" size="40" name="subject" id="subject" value="" class="required" />
		</div>

		<div>
			<label for="message"><strong>Message:</strong></label>
			<textarea rows="5" cols="60" name="message" id="message" class="required"></textarea>
		</div>
	    <input type="submit" value="Send Message" class="submit" name="submit" />
	</form>
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: echo $_SERVER['PHP_SELF'];

Post by Dr.CSS »

CMSMS version 1.7 is no longer supported so you need to upgrade...

Any reason you don't just use the Form Builder module?...
ronanski
New Member
New Member
Posts: 7
Joined: Tue Feb 08, 2011 9:09 pm

Re: echo $_SERVER['PHP_SELF'];

Post by ronanski »

Hello,

thank you for the response.

I have tried the form builder however I was getting an error with the captcha - on submission the captcha came back as being incorrectly entered (although it was entered correctly.) The form data was also submitted successfully even though the captcha returned the error.

The form I am trying to use here uses jquery for validation. It works perfectly when I place it on a page outside cmsms. On my cmsms page it works up until the point where it should display the submission success html - the form data is sent however the page redirects to the site root. I'm not great at php but instinct tells me that echo $_SERVER['PHP_SELF']; may be the problem?

cheers,
R
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: echo $_SERVER['PHP_SELF'];

Post by Dr.CSS »

What errors were you getting from captcha?...
ronanski
New Member
New Member
Posts: 7
Joined: Tue Feb 08, 2011 9:09 pm

Re: echo $_SERVER['PHP_SELF'];

Post by ronanski »

The error was that the captcha was incorrectly entered - although it was not. The form data was sent successfully despite this error. To the user, it appeared that their information was not submitted resulting in multiple submission attempts.

My newer form is a nice jquery implementation, however as mentioned it will not work properly inside cmsms and I'm not sure why.

cheers,
R
Post Reply

Return to “The Lounge”