There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Web Design & Development
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming google hard drive hardware hdmi internet laptop malware memory missing monitor motherboard mouse netgear network printer problem ram registry router security slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
$_post

Reply  
Thread Tools
dudeking's Avatar
Member with 483 posts.
 
Join Date: Feb 2007
Location: UK, Midlands
Experience: Advanced
26-May-2007, 08:44 AM #1
$_post
My contact script uses $_POST which dosnt work with globles turned off, what else can I use?

PHP Code:
<?php
    $do
=$_POST['do'];
    if (
$do == '') {
?>
<div id="contact">
</div>
<div id="frm">
    <form name="mail" method="post" action="index.php?do=mail">
        <input type="hidden" name="ip" id="ip" value="<?php echo $ip?>" />
        <div>
            <input name="subject" type="text" class="emailtext" id="subject" onfocus="if(this.value=='Subject'){this.value='';}" onblur="if(this.value==''){this.value='Subject';}" value="Subject" style="border-width:0px;margin:0px;padding:5px;text-align:center;vertical-align:middle;" />
        </div>
        <div>
            <input name="realname" type="text" class="emailtext" id="realname" onfocus="if(this.value=='Your Name'){this.value='';}" onblur="if(this.value==''){this.value='Your Name';}" value="Your Name" style="border-width:0px;margin:0px;padding:5px;text-align:center;vertical-align:middle;" />
        </div>
        <div>
            <input name="email" type="text" class="emailtext" id="email" onfocus="if(this.value=='Your Email Address'){this.value='';}" onblur="if(this.value==''){this.value='Your Email Address';}" value="Your Email Address" style="border-width:0px;margin:0px;padding:5px;text-align:center;vertical-align:middle;" />
        </div>
        <div>
            <textarea name="message" id="message" onfocus="if(this.value=='Your Message'){this.value='';}" onblur="if(this.value==''){this.value='Your Message';}">Your Message</textarea>
        </div>
        <div>
            <br />
            <input type="hidden" name="do" value="1" />
            <input name="Submit" id="Submit" type="submit" value="" />
            <input name="Reset" id="Reset" type="Reset" value="" />
        </div>
    </form>
</div>
<?php
} else {
    function 
isemail($email)
        {
           
$regex '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$';
           if (
eregi($regex$email)) return true;
           else return 
false;
        }
    
$feed "\r\n";
    
$recipent 'dudelee@gmail.com';
    
$name $_POST['realname'];
    
$address $_POST['email'];
    
$ip $_POST['ip'];
    
$subject $_POST['subject'];
    
$message $_POST['message'];
        
    If ((
isemail($address) == true) && (strlen($name) > 1)  && (strlen($message) > 1)) { 
        
        
$full $message.$feed.$feed.$name.$feed.$address.$feed.$ip;
        
$headers 'From: '.$address;
        
mail($recipent$subject$full$headers);
        
        echo 
"
        <div id=\"sent\">
        </div>
        <div>
            Your message has been sent.
            <br />
            <br />
        </div>
        "
;
        
    } else { 
        
        echo 
"
        <div id=\"error\">
        </div>
        <br />
        It looks like you forgot something or you didn't provide a valid email address.
        <br />
        Please go back and complete all the fields.
        <br />
        <br />
        <div class='textlink'>
            <a href='javascript: window.history.go(-1)'>
                Click here to return
            </a>
        </div>
        "
;
    }
}
?>
http://dudeking.co.uk/contact
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
26-May-2007, 09:50 AM #2
$_POST should work with super globals turned off.

Does that give you an error? If not why doesn't it work?
dudeking's Avatar
Member with 483 posts.
 
Join Date: Feb 2007
Location: UK, Midlands
Experience: Advanced
26-May-2007, 10:20 AM #3
The message I get is
Quote:
Notice: Undefined index: do in /home/fhlinux172/d/dudeking.co.uk/user/htdocs/include/scripts/contact/contact.php on line 2
and all that happens when a message is sent with the script is the page is refreshed, no message sent message is displayed and the message isnt sent.
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
26-May-2007, 10:52 AM #4
Problem with your host. Turn error_reporting off by putting this code in the beginning of the file.

error_reporting(0);

It should work currently though.
namenotfound's Avatar
Computer Specs
Senior Member with 3,003 posts.
 
Join Date: Apr 2005
Location: New York
Experience: no man can be my equal
26-May-2007, 11:00 AM #5
Quote:
Originally Posted by MMJ
$_POST should work with super globals turned off.

Does that give you an error? If not why doesn't it work?
I think you mean "with register globals turned off"

$_POST is a Super Global http://us.php.net/manual/en/reserved.variables.php
dudeking's Avatar
Member with 483 posts.
 
Join Date: Feb 2007
Location: UK, Midlands
Experience: Advanced
26-May-2007, 12:28 PM #6
Im asking my host to turn register globals on I can't work with them off.

Thanks for the help
harmor's Avatar
Senior Member with 117 posts.
 
Join Date: Mar 2007
Experience: Intermediate
26-May-2007, 07:58 PM #7
Change this
PHP Code:
if ($do == '') { 
To
PHP Code:
if (empty($do)) { 
dudeking's Avatar
Member with 483 posts.
 
Join Date: Feb 2007
Location: UK, Midlands
Experience: Advanced
26-May-2007, 08:42 PM #8
Thanks harmor but still get the message Notice: Undefined index: do in /home/fhlinux172/d/dudeking.co.uk/user/htdocs/include/scripts/contact/contact.php on line 2

Web Host told me they cannot turn on globals from the server, I have do to it, how can I turn them on?
__________________
Thanks, Eddie
Software Engineering Student, NTU
harmor's Avatar
Senior Member with 117 posts.
 
Join Date: Mar 2007
Experience: Intermediate
27-May-2007, 01:34 AM #9
I'm sorry.

Change
PHP Code:
$do=$_POST['do'];
if (
$do == '') { 
To
PHP Code:
if(empty($_POST['do'])) { 
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
27-May-2007, 05:54 AM #10
Your email script is inscure and could be used by spammers. You might want to look up "email injection" and fix it, or just use a different script like this one.
dudeking's Avatar
Member with 483 posts.
 
Join Date: Feb 2007
Location: UK, Midlands
Experience: Advanced
27-May-2007, 06:01 AM #11
This script was written for me before I new PHP and I have just been copying it around to every site I build. I will look into more secure email scripts now.

Please can some one tell me how to enable globals? The default value for them on PHP5 is off rather than on as with PHP4. Enabling them would solve 99% of the problems I am having. Would I gain anything from having them off?
__________________
Thanks, Eddie
Software Engineering Student, NTU
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
27-May-2007, 06:08 AM #12
The script you posted doesn't use register_globals, what's the problem you're having with it?
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
27-May-2007, 07:46 AM #13
Did you try what harmor posted?
dudeking's Avatar
Member with 483 posts.
 
Join Date: Feb 2007
Location: UK, Midlands
Experience: Advanced
27-May-2007, 08:01 AM #14
Yeah I've tried it look here http://dudeking.co.uk/contact/index.php

Fill it in, all that happens is that the form resets, no message is sent.
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
27-May-2007, 08:45 AM #15
<input type="hidden" name="ip" id="ip" value=
"
<br /><b>Notice</b>: Undefined variable: ip in <b>/home/fhlinux172/d/dudeking.co.uk/user/htdocs/include/scripts/contact/contact.php</b> on line <b>8</b><br />
" />
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:06 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.