none
Using PHP to gather data and to send in email and Required fields. RRS feed

  • Question

  • Posted a Q yesterday about this same issue but was trying to use ASP.

    Decided after doing some more digging that it would be better to use PHP in my application.

    I have my form all set up. The Send.PHP has had all the syntax errors corrected and seems to be functioning correctly.

    The only 2 issues I have are:

    1. How do I make some of the fields required?

    2. When I test it I do not get the email. I need to check that to see if I have the correct data coming to me. I do not see any errors (but there still could be some).

    Here is the Send.PHP coding:

    <?php
    $First=$_POST['First_Name'];
    $Last=$_POST['Last_Name'];
    $Email=$_POST['Email'];
    $Phone=$_POST['Phone'];
    $Position=$_POST['Position'];
    $Resume=$_POST['Resume'];
    $Portfolio=$_POST['Portfolio'];
    $Salary=$_POST['Salary'];
    $Start=$_POST['Start'];
    $Last=$_POST['Last'];
    $Comments=$_POST['Comments'];

    $message="Name: ".$First. "\r\n" .$Last. "\r\n" . "Email: " .$Email. "\r\n" . "Phone: " .$Phone. "\r\n" . "Position: " .$Position. "\r\n" . "Resume: " .$Resume. "\r\n" . "Portfolio: " .$Portfolio. "\r\n" . "Salary: " . $Salary. "\r\n" . "Start: " .$Start. "\r\n" . "Last Company: " .$Last. "\r\n" . "Comments: " .$Comments;

    $to='myname@myprovider.com';
    $subject='Job Application';
    $Sum =$_POST['Sum'];

    if ($Sum==11)
    {
    mail($to,$subject,$message);
    echo 'Thanks for the submission.';
    }
    else
    {
    echo 'Did you answer the math question? Your comment was not sent.';
    } ?>

    I know it has to be something simple. I am very new to this function.

    Thanks

    Bob

    Thursday, December 15, 2016 4:18 PM

Answers

  • Thanks for the reply. I completely understand and agree with what you said above.

    I was figuring that since Expressions does have some PHP Snipets in it that I would  start here with my questions first. I went to Godaddy because of the first reply to my questions.

    I have just gotten into PHP, like 2 days ago. It is very confusing to me so far.

    I will do more googling and check out the web site you provided.

    Was hoping that it would be as easy as drag and drop but I was wrong.

    Bob

    • Marked as answer by davet102 Thursday, December 15, 2016 9:59 PM
    Thursday, December 15, 2016 9:59 PM

All replies

  • Sorry, forgot to add that I do have it out on my providers server. (Godaddy)

    It is live. No link to this page yet, but I can test it by typing in the direct link.

    Bob

    Thursday, December 15, 2016 4:20 PM
  • Two things:

    First, contact forms on GD must meet their security and other requirements. Call tech support to see if yours does.

    Second, GD has (configurable) contact forms that they provide for their users. Talk to tech support about how to set it up if that page doesn't explain it clearly enough. It should satisfy your requirements.

    That should get you going...  ;-)

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    • Edited by paladyn Friday, December 16, 2016 12:11 AM
    Thursday, December 15, 2016 6:33 PM
  • Got the emailing portion figured out. Everything is being emailed correctly.

    They were no help as far as making fields required and formatting them.

    Bob

    Thursday, December 15, 2016 7:13 PM
  • GoDaddy is a hosting provider, not a free coding company. Of course they won't tell you how to require fields in PHP. (If their own provided forms have that option, you would be better off using their forms.)   This forum is also not a PHP coding forum - it's for help using Expression Web. Learning PHP is up to you. Google for "https://www.google.com/#q=how+to+make+form+fields+mandatory+in+php ".  One result is for an answer on w3schools.com, which has a section where you can learn PHP, including a page on testing for and enforcing required fields in forms:  http://www.w3schools.com/php/php_form_required.asp


    Kathleen Wilber
    BrightWillow - Asp.Net Applications

    Thursday, December 15, 2016 9:38 PM
  • Thanks for the reply. I completely understand and agree with what you said above.

    I was figuring that since Expressions does have some PHP Snipets in it that I would  start here with my questions first. I went to Godaddy because of the first reply to my questions.

    I have just gotten into PHP, like 2 days ago. It is very confusing to me so far.

    I will do more googling and check out the web site you provided.

    Was hoping that it would be as easy as drag and drop but I was wrong.

    Bob

    • Marked as answer by davet102 Thursday, December 15, 2016 9:59 PM
    Thursday, December 15, 2016 9:59 PM
  • By the way, you don't mark your own response as the answer, but the post or posts that provided the answer.

    I'm sure you'll figure it out by reading the page I provided.



    Kathleen Wilber
    BrightWillow - Asp.Net Applications

    Thursday, December 15, 2016 10:42 PM
  • I will just mention that, had you chosen asp.net instead of php, what you are trying to do would have been dead simple using the Required Field Validator control. You would have dragged a Required Field Validator onto the page, indicated which field was required, typed in the error message you wanted to show if the field had not been filled in, and that's that.

    Not saying anything negative about php - I don't use it but lots of people do.

    Just sayin'


    ClarkNK AKA HomePage Doctor
    Database Tutorials Using ASP.NET Controls
    My recommended web hosting company: RDOServers

    Friday, December 16, 2016 1:31 PM
  • After posting the question, I have created one using ASP and you are correct. I was able to create the required fields and format the data I needed.

    Still leaning toward using ASP.

    Still need to figure out how to get the submit button to email me the info and would like to be able to have the person filling this out to upload a file and attache it to that email.

    Bob

    Friday, December 16, 2016 3:26 PM
  • Bob, please get your terminology straight. ASP is NOT ASP.NET. They are two different languages, which require two completely different support structures, and have completely different syntaxes, and you cannot discuss development questions in one using the terminology of the other.

    Furthermore, while EW provides direct support for both PHP and ASP.NET, it does not do so for ASP. There is no Intellisense, no built-in menu support for programming constructs such as is supplied for PHP, and you cannot even run ASP pages from the EW editor. The EW development server does not support ASP, nor do browsers natively, so you would have to upload and test ASP pages on a live server which does support it.

    EW does not support ASP, and does support ASP.NET. If that is what you are discussing, please say so.

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Friday, December 16, 2016 6:36 PM
  • Well, you can run ASP pages from EW, but you have to (as I have done when taking on old ASP sites for clients) jump through a couple of hoops: set the site up in your local IIS, make sure IIS was installed with ASP support turned on, and use the IIS address in the Site Preview settings, not EW's built-in development server.

    But yes, ASP is not ASP.NET, and EW provides no intellisense, etc. for ASP.



    Kathleen Wilber
    BrightWillow - Asp.Net Applications

    Friday, December 16, 2016 6:56 PM
  • Well, you can run ASP pages from EW, but you have to (as I have done when taking on old ASP sites for clients) jump through a couple of hoops: set the site up in your local IIS, make sure IIS was installed with ASP support turned on, and use the IIS address in the Site Preview settings, not EW's built-in development server.

    Heh, heh... well, yes, you can in fact run ASP if you're willing to go to all that trouble, but I wasn't getting into all that in my post.  ;-)

    OTOH, Bob, if you're trying to test your email app using the EW development server, then that ain't hap'nin' either. You see, the Cassini development server in EW does not support SMTP, which, AFAIK, is the sine qua non for sending ASP.NET emails. That is why your tests are (silently) failing. PHP, as you have seen, has its own in-built methods that do not require an SMTP server. (BTW, some hosts, such as Arvixe, find those methods to be insecure, and they will not work on their servers.)

    So, if you want to test your form locally, you're going to have to install/activate IIS, then configure it for SMTP support, then configure EW to use the IIS instance instead of the built-in Cassini server to test your forms. Either that, or test remotely by uploading them to your live server for testing.

    Oh, hell, that reminds me. You do have your hosting on a Windows server, right? A Windows IIS server is required to run ASP.NET (not getting into the MONO Project here, except to say that it does not fully support ASP.NET), so if you are on a Linux server, you're going to have to change plans to a Windows server plan, or if they don't offer them (some don't), you'll have to change hosting providers.

    Perhaps ironically, if you're on a Linux host server, it's probably running a flavor of Apache, which does have direct support for Classic ASP (the other one, not ASP.NET—I do so wish that MS had simply named the new framework something as completely different from the old name as the framework itself was from what came before, perhaps just plain old ".NET", which is what it ended up being called anyway; that would've avoided a lot of confusion), and there are several contact forms for ASP. But, again, you would have to "jump through hoops" to test those locally.

    Now do you see why it is important to differentiate (after all, it only takes three extra letters) exactly which version of programming language you're speaking of?

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    • Edited by paladyn Friday, December 16, 2016 9:00 PM
    Friday, December 16, 2016 8:32 PM