Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 24
  1. #1
    Junior Member
    Join Date
    Mar 2015
    Posts
    14
    Member #
    47887

    problems with linking contact form with php script

    hi everyone

    new to web design and wanted to get some tips and advice.this is the problem i have i wanted to ask what are the stepts for linking a contact form to the php script and do you have to put any thing else on the hosting server for it to work as i am not sure how to link the contact form to the php script to process the worm and also does the contact form and the php script have to be named the same.thabks in advance for everyone taking time out

    regards

    vropes

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,723
    Member #
    5580
    Liked
    718 times
    First of all, when you say "contact form", do you mean a form that sends an email to someone? Or do you mean a "form" in general, where the form data gets stored somewhere or does other things?

    The very basic "form" for you to test would be like this:

    This is one script, called "test.php":

    Code:
    <form action="processform.php" method="post">
    What is your name: <input type="text" name="yourname"><br />
    <input type="submit" name="submit" value="Submit Your Name">
    </form>
    This is the other script, called "processform.php":

    Code:
    <?php
    if($_POST['yourname']){
    echo "Your name is ".$_POST['yourname']."<br />";
    }
    else{
    echo "You did not enter a name.<br />";
    }
    ?>

    Google has thousands of PHP contact form scripting examples.


  4. #3
    Junior Member
    Join Date
    Mar 2015
    Posts
    14
    Member #
    47887
    hi all

    problem i seem to be having is the contact for is forwarding messages to email but the message seems to be blank there is no text in the name section email or message its all blank
    Last edited by vropes; Mar 16th, 2015 at 05:29 AM. Reason: forgot to add

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,723
    Member #
    5580
    Liked
    718 times
    This part:

    <form action="action: mailto:tester11@hotmail.com" method="get" enctype="enctype:text/plain" name="form1" id="form1">

    Needs to be a reference to another PHP script that sends the email.

    Like this:

    <form action="processform.php" method="post" enctype="enctype:text/plain" name="form1" id="form1">

    Then, the PHP script called "processform.php" processes your script and sends the email. You of course have to write that script. And you may want validation of data, perhaps a captcha, a confirmation, a thank-you page, etc. Too many options to mention ... which is why we can't provide that script. There are many examples on Google though.


  6. #5
    Junior Member
    Join Date
    Mar 2015
    Posts
    14
    Member #
    47887
    <?php



    /* Email Variables */
    $emailSubject = 'indie music!';
    $webMaster = 'tester11@hotmail.com';



    /* Data Variables */
    $email = $_POST['email'];
    $name = $_POST['name'];
    $message = $_POST['message'];



    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Email: $email <br>
    message: $message <br>
    EOD;
    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body,
    $headers);


    /* Results rendered as HTML */
    $theResults = <<<EOD
    <html>
    <head>
    <title>sent message</title>
    <meta http-equiv="refresh" content="3;URL=mydomain i put here">
    <style type="text/css">
    <!--
    body {
    background-color: #444;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 20px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #fec001;
    text-decoration: none;
    padding-top: 200px;
    margin-left: 150px;
    width: 800px;
    }
    -->
    </style>
    </head>
    <div align="center">your message has been successfully sent we will contact you shortly</div>
    </div>
    </body>
    </html>
    EOD;
    echo "$theResults";
    ?>
    Last edited by vropes; Mar 16th, 2015 at 05:42 AM. Reason: forgot to add

  7. #6
    Junior Member
    Join Date
    Mar 2015
    Posts
    14
    Member #
    47887
    i have added php script also which i use to process the form the script is forwarding the emails to me but the messages and the name and email do not show up in the email.in the email it says unknown sender
    Last edited by vropes; Mar 16th, 2015 at 10:16 AM.

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,723
    Member #
    5580
    Liked
    718 times
    Post your website so I can see the actual form that gets filled out.


  9. #8
    Junior Member
    Join Date
    Mar 2015
    Posts
    14
    Member #
    47887

    problems with linking contact form with php script

    Quote Originally Posted by mlseim View Post
    Post your website so I can see the actual form that gets filled out.
    <head>

    <title>music</title>
    <!-- indie -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> contact form</title>
    <style type="text/css">
    body {
    background-color: #069;
    }
    body,td,th {
    font-size: large;
    font-weight: bold;
    color: #000;
    }
    </style>
    <script type="text/javascript">
    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    </script>
    </head>

    <body>
    <p><img src="cooltext1931496504.png" width="966" height="86"></p>
    <p>&nbsp;</p>
    <p><a href="index.html"><img src="Back button.png" width="129" height="40"></a></p>
    <p>&nbsp; </p>
    <form action="action:contactform1.php" method="get" enctype="enctype:text/plain" name="form1" id="form1">
    <p>&nbsp;</p>
    <p>
    <label for="name3">name</label>
    <input name="name" type="text" id="name4" value="" size="50">
    <label for="jjjj"></label>
    </p>
    <p>&nbsp;</p>
    <p>
    <label for="Email">Email</label>
    <input name="Email" type="text" id="Email" size="50" maxlength="30" />
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>
    <label for="Message">Message</label>
    <textarea name="Message" cols="60" rows="10" id="Message"></textarea>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p><a href="contact form1.php"><img src="submit button.png" width="140" height="40"></a></p>
    <p>&nbsp;</p>
    </form>
    <p><a href="button.png"></a><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('submit','','cooltext192 6436576.png',1)"></a></p>
    <p>&nbsp;</p>
    <p>&nbsp; </p>
    </body>
    </html>
    Last edited by vropes; Mar 19th, 2015 at 07:32 AM.

  10. #9
    Junior Member
    Join Date
    Mar 2015
    Posts
    14
    Member #
    47887
    forgot to mention i get this message in the email when i tested contact form {unknown sender}

  11. #10
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,723
    Member #
    5580
    Liked
    718 times
    This is still wrong:
    <form action="action: mailto:myemail" method="get" enctype="enctype:text/plain" name="form1" id="form1">

    See post #4.

    You didn't change anything.



Page 1 of 3 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:58 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com