-4

I have a form and trying to send it using PHP but when I visit the page all I see id this:

Parse error: syntax error, unexpected '.' in /home/n60web6/public_html/download/demo/Booking/index.php on line 74

I tried everything but can't seem to work this out. Please show me what I am doing wrong.

Thanks

<body>
        <?php
            //if "email" variable is filled out, send email
            if (isset($_REQUEST['email']))  {

                //Email information
                $admin_email = "hipevideos@gmail.com";
                $name = $_REQUEST['name'];
                $email = $_REQUEST['email'];
                $phone = $_REQUEST['phone'];
                $reason = $_REQUEST['reason'];
                $date = $_REQUEST['date'];
                $advice = $_REQUEST['advice'];
                $comment = $_REQUEST['comment'];

                //send email
                mail($admin_email, "$name", .$phone "$reason", .$date "$advice", .$comment "From:" . $email);

                //Email response
                echo "Thank you for contacting us! We will be intouch.";
            }

            //if "email" variable is not filled out, display the form
            else  {
        ?>

        <form action="" method="get">
            <fieldset>
                <legend>Personal Information</legend>
                <label for="name">Name</label><input type="text" name="name" id="name" required placeholder="Your name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters"><br>
                <label for="email">Email</label><input type="text" name="email" id="email" required placeholder="Your email" pattern="[a-zA-Z]{3,}@[a-zA-Z]{3,}[.]{1}[a-zA-Z]{2,}" title="Please enter a valid email address"><br>
                <label for="phone">Phone</label><input type="tel" name="phone" id="phone" required placeholder="Enter a phone number" pattern="[0-9]{1} [0-9]{3} [0-9]{3} [0-9]{4}" title="Please enter phone number in this format # ### ### ####"><br>
                <label for="reason">Service Needed</label><select name="reason" id="reason" required>
                <option value=""> </option>
                <option value="general">General</option>
                <option value="webDesign">Web Design</option>
                <option value="seo">SEO</option>
                <option value="ssm">SMM</option>
                </select>
            </fieldset>
            <br>
            <fieldset>
                <legend>Project Details</legend>
                <label for="date">Project Start date</label> <input type="date" name="date" id="date" min="04-10-2015">
                <p>Do you need design advice?</p>
                <label for="yes">Yes</label><input type="radio" name="advice" id="yes" value="yes">
                <label for="no">No</label><input type="radio" name="advice" id="no" value="no">
                <br><br>
                <p>What information should we know about your project?</p>
                <label for="comment" class="messageLabel"></label><textarea name="comment" id="comment" placeholder="Give us as much information." required title="Please give us some information about the project" class="message"></textarea>
                <br><br>
                <input type="image" src="SEND.png" class="send">
            </fieldset>
        </form>
        <?php
            }
        ?>
    </body>
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Dwayne
  • 1
  • 2
  • 1
    What is line 74? There isn't 74 lines here. – Jay Blanchard Apr 10 '15 at 15:43
  • `.phone` found it! 100pt. for me? (<- place the concatenation dot after the variable to concatenate it with the string; Same for all other variables in the `mail()` function) – Rizier123 Apr 10 '15 at 15:44
  • What do you expect `.$phone "$reason"` to do? – fvu Apr 10 '15 at 15:46
  • More than just `.$phone` - pretty much this whole function call looks like a syntax error : `mail($admin_email, "$name", .$phone "$reason", .$date "$advice", .$comment "From:" . $email);` – CD001 Apr 10 '15 at 15:47
  • @CD001 Indeed, there is a pattern recognizable there, and that's why I asked OP to explain his expectations. – fvu Apr 10 '15 at 15:47
  • Thanks for the quick response. This is what I did but still getting the error. mail($admin_email, ".$name", .$phone ".$reason", .$date ".$advice", .$comment "From:" . $email); any idea – Dwayne Apr 10 '15 at 15:49
  • 1
    @Dwayne Read about `.` the [php string concatenation operator](http://php.net/manual/en/language.operators.string.php) which you seem to misunderstand. Hence my question: what do you want to achieve? In php syntax `.$phone "$reason"` is gibberish, but what do you actually *want* it to do? – fvu Apr 10 '15 at 15:54
  • You need to go back and look at PHP's [`mail()`](http://php.net/manual/en/function.mail.php) function. It is hard to look at your code and figure out how you're trying to use it in the context of that function. If you can describe what you're trying to do within that context we can likely help. – Jay Blanchard Apr 10 '15 at 17:29

1 Answers1

0

This entire line has bad syntax from beginning to end:

mail($admin_email, "$name", .$phone "$reason", .$date "$advice", .$comment "From:" . $email);
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • 1
    Ninja'd my comment by about 11 seconds - *shakes fist* - curse you! :P – CD001 Apr 10 '15 at 15:48
  • LOL @CD001! Friday Ninja Day! – Jay Blanchard Apr 10 '15 at 15:48
  • OK the syntax is wrong. How do I fix it? I am leaning and would really appreciate the help. – Dwayne Apr 10 '15 at 15:54
  • @Dwayne Did you read my comment? http://stackoverflow.com/questions/29565544/php-syntax-error#comment47280640_29565544 – Rizier123 Apr 10 '15 at 15:54
  • Yes I did what you suggested but the error is still there. – Dwayne Apr 10 '15 at 16:01
  • @Dwayne Then you either didn't do the right thing. OR you don't show us your **full** and **real** code(file). – Rizier123 Apr 10 '15 at 16:06
  • My be I am just not getting it and if that's the case I will keep trying as I have a never give up mind set. just please take one last look and post the correct code where I am missing up so I may get it. Thanks or your help. – Dwayne Apr 10 '15 at 16:18
  • @Dwayne the thing here is that we're not clairvoyants, and your code makes as little sense to the php interpreter as it does to us. I asked you a couple of times before, ***what do you want that piece of code to do*** or stated otherwise, what do you expect will come out of that code fragment? Just explain it in plain english if you have no idea at all on how to express in code what you want, but don't make us guess. – fvu Apr 10 '15 at 22:05