1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Script does not work even though it is correct.

Discussion in 'PHP' started by askscript, Apr 4, 2010.

  1. #1
    Hi, could you guys help me out to understand this. I am a beginner PHP learner.

    I created this form and try to learn about urlencode ()

    Form:
    And create this PHP script ( handle_post.php) to run the form.
    It gives me this error which starts at the $name = urlencode($name);
    I am learning it from a book and i did what the book told me to and i still do not understand what i did. can anyone help? thanks.
     
    askscript, Apr 4, 2010 IP
  2. MattChicago

    MattChicago Peon

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hurmm usually php process files (script) does not have html in it its just php code nothing else.


    For Example this is a simple process form script below i used for a site i built. below you will see $zip and other form fields replace them and add yours, then put the code below into a php page and its done, be sure to put in your domain name (for return back or the thank you page for the contact and also where it says email put in your email address so it will notify you of the form contents.

    <?php
    @extract($_POST);
    $name = stripslashes ($name);
    $email = stripslashes ($email);
    $subject = stripslashes ($subject);
    $text = stripslashes ($text);
    $message = $subject . "\n" . $name . "\n" . $address . "\n" . $city . "\n" . $state . "\n" . $zip . "\n" . $phone . "\n" . $services ."\n" . $month1 . $month  . "\n" .  $day1 . $day . "\n" . $year1 . $year . "\n" .  $time . "\n" . $email . "\n" . $text;
    mail ('email address here',$subject,$message,"From: $name <$email>");
    header ("location:domainnamehere");
    ?>
    
    Code (markup):
     
    MattChicago, Apr 4, 2010 IP
  3. askscript

    askscript Member

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    i don't think that is the cause of it. The book i am learning from does that as well. The whole quote that i put up is in exact code as shown in the book.
     
    askscript, Apr 4, 2010 IP
  4. MattChicago

    MattChicago Peon

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i dunno i just put in the code i used for my contact page i made for a site, so you can use that process stuff i posted if you like and configure it for your site.
     
    MattChicago, Apr 4, 2010 IP
  5. junaids

    junaids Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    @ handle_post.php
    try changing this
    to this

     
    junaids, Apr 5, 2010 IP
  6. askscript

    askscript Member

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    Hi junaids,

    The main point of the problem is not the ";" but thanks for pointing out. It is the "urlencode" which doesn't work and show error in that line.
     
    askscript, Apr 5, 2010 IP
  7. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #7
    It's this line:

    You need to close the bracket:

     
    mfscripts, Apr 5, 2010 IP
  8. dragongball

    dragongball Guest

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    this code false at line 28?
    have beter

    <?print "<div>
    Thank you, $name for your posting:
    <p>$posting</p>
    </div> ";
    ?>
    this is true
     
    dragongball, Apr 6, 2010 IP
  9. askscript

    askscript Member

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #9
    Oh , that is the retype of the code to post it here. Yes, the bracket is initially close and it does not work.. that is not the cause of the problem.
     
    askscript, Apr 6, 2010 IP
  10. askscript

    askscript Member

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #10
    This is line 28.

     
    askscript, Apr 6, 2010 IP
  11. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #11
    The only syntax errors you have in the script is the missign semi-colon on line 25 and the missing closed bracket on line 29.... I have fixed these on a test server and the script works ok.

    If you are still seeing a problem, what error are you getting?
     
    lukeg32, Apr 7, 2010 IP
  12. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #12
    It might be easier for us to help if you copy & paste your code in rather than retype it. It's hard to find the problem areas within your code, without seeing the exact code you're using...
     
    mfscripts, Apr 7, 2010 IP
  13. askscript

    askscript Member

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #13
    The code is at the very first post. It is from my dreamweaver, sorry i meant, i type it in my dreamweaver and then copy and paste it here. I have filled up the missing colon and brackets. But i still get the error. I am using XAMPP to test out my code. Is it because of that?
     
    askscript, Apr 7, 2010 IP
  14. askscript

    askscript Member

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #14
    oh i get the script working already. i do not know what went wrong but everything is fine now. Thanks for your help guys.
     
    askscript, Apr 7, 2010 IP