New to coding
Results 1 to 13 of 13

Thread: New to coding

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    7

    Wink New to coding

    Hello I am building my first website and I have come across this powerful language and I'm having the hardest time getting it to work.
    I am building my contact page and I have several email recipients for visitors to send messages to. the issue is that I can't seem to find any information on the code that would allow that to happen and then even when I find codes I can't seem to get them to work when I load the PHP file on to my server... for instance my current code is:
    <?php
    if (empty($_POST) === false) {
    $errors = array();
    $FirstName = $_POST['FirstName'];
    $LastName = $_POST ['LastName'];
    $email = $_POST['email'];
    $to = "Garood.Mocombe@M-Fin.com";
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    mail ($to,$subject,$message);

    echo "Message Sent!";
    }

    ?>
    when I hit send on the page it echos out the entire code as you see it up top.
    can anyone give me some ideas on how to fix this? and on the code that would allow me to set up multiple email recipients?

  2. #2
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Quote Originally Posted by GMan78 View Post
    when I hit send on the page it echos out the entire code as you see it up top.
    can anyone give me some ideas on how to fix this?
    that would indicate that PHP is not parsing your script at all. Are you sure that your server has PHP installed?

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    I think it is because I was able to do the hello world code and it worked fine... but when I began on my own code it wouldn't work

  4. #4
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    (When you post php code, use the forum's [php][/php] BBCode tags.)

    Are there other parts, or is this your entire script?
    Is your server configured to recognize this file as a php script (in most cases, the script's filename must end in .php)?

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    the code that I posted is all I have so far. the file extension is .php... I've tried everything.

  6. #6
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Try clearing your browser cache. Are you running these pages locally or on the net?

    Could you post the HTML page that you're submitting the form from?

  7. #7
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    my permissions to share html and img is off how do I get that turned on?

  8. #8
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    sorry I didn't get what you were asking correctly until just now here it is.


    <html>
    <header>
    <title>My Business Site.</title>
    <link rel="stylesheet" type="text/css" href="M-fin.css">
    </header>
    <body>
    <center>
    <Div class="banner">
    <img src="M-Fin Webpage/Pages/Images/top background.png" width="1150" height="150">
    </Div>

    <Div class="Nav">
    <a href="M-Fin.html">Home </a> | <a href="About.html"> About</a> | <a href="Services.html"> Services</a> | <a href="Careers.html"> Careers</a> | <a href="Blog.html"> Blog</a> | <a href="Contact.html"> Contact</a>
    </Div>


    <Div class="WrapperC"><br><br>
    <form action="send_contact.php" method="POST">
    <h3><b>Contact Us</b></h3>
    <p>Please take the time to let us know how we can help you!</p>
    <b>First Name:</b> <input type="text" name="FirstName" id="FirstName">
    <b>Last Name:</b> <input type="text" name="LastName" id="LastName"></p>
    <b>Your EMail:</b> <input type="text" name="email" id="email"><p>
    <b>Recipient:</b>
    <select name="person">
    <option value="Garood.Mocombe@M-Fin.com">Garood Mocombe</option>
    <Option value="Linda.Craddock@M-Fin.com">Linda Craddock</option>
    <Option value="Info@M-Fin.com">Customer Service</option>
    </select><br><br>
    <p>Please be detailed as our goal is to provide the highest level of service.</p>
    <b>Subject:</b> <input name="subject" type="text" id="subject">
    <p></p>




    <p><b> Message:<b><br><textarea rows="10" cols="50" name="message">Please Enter Message Here!</textarea><p></p>

    <input type="submit" name="submit" value="Submit"><input type="reset" name="submit2" value="Reset"

    onclick="window.open(setit.options[setit.selectedIndex].value)">
    </form>



    </Div>



    <br><br>

    </body>
    </html>

  9. #9
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,720
    Quote Originally Posted by GMan78 View Post
    my permissions to share html and img is off how do I get that turned on?
    So .... you're NOT running this on a webserver?
    Quote Originally Posted by traq
    Are you running these pages locally or on the net?
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  10. #10
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    I'm running them locally

  11. #11
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,720
    PHP has to be served by a properly configured web server; that would explain why the code appears as plain text instead of server-rendered output.
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  12. #12
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    I was told that my wamp server was good enough to do that so long as it could process PHP is that not correct? I did a test with the "hello world" code and it worked fine.

  13. #13
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    At the top of this script (the one you're having trouble with), immediately after the opening <?php, add:
    PHP Code:
    die( phpversion() ); 
    and post the result.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •