/    Sign up×
Community /Pin to ProfileBookmark

Contact form PHP

Hi, I just finished my portfolio and I want to add a contact form and I want to make it work with PHP.
I watched a tutorial on how to code it. it doesn’t seem that hard but I have some questions.

  • 1. Do I need to install PHP in order for the PHP to work?

  • 2. Is there any way I can find out if the contact form works before I upload it online?

  • 3. Can I write a php in HTML? I tried with <?PHP ?> but doesn’t seems to work, maybe because I need to install it.
  • to post a comment
    PHP

    6 Comments(s)

    Copy linkTweet thisAlerts:
    @ginerjmJul 21.2019 — Maybe you need to do some reading to teach yourself these things?

    Portfolio? What is that? An app? Is it running on your very own server or your laptop/PC? If so - then of course you have to install PHP! If you are purchasing/using a provider's services to host your 'portfolio' then hopefully they are offering PHP as a part of their package to you so no you don't have to install it.

    Can you write php in html? Php works to provide you the ability to code logic that does things for you. You then compose an html page with your php script and add the results of your logic to it and send it all to the client. They are 2 different things and when a script is written well they tend to be separate pieces of your script with the php code starting it off and html finishing it, logically. Try not to intermingle them even tho you will probably want to do that. It makes for a horrible debugging experience (and maintenance), trying to read thru a bunch of html just to try and find the code that is causing the problem.

    As for testing - you will have to work that out for yourself. Some people using outside hosting will load up an environment on their pc to do their testing (read up on things like XAMPP). Others will have a separate folder on their server to hold their code while they are testing it from the server installation.
    Copy linkTweet thisAlerts:
    @codyhillauthorJul 21.2019 — @ginerjm#1606557 Thx. All I need is just a simple code to make the form work. I was reading about php but I couln't find anything specific
    Copy linkTweet thisAlerts:
    @SempervivumJul 21.2019 — 1. Do I need to install PHP in order for the PHP to work?[/quote]Yes, but on common webspace it is already installed.
    2. Is there any way I can find out if the contact form works before I upload it online?[/quote]Yes, you can. Note that you will need PHP in order to code a contact form and PHP needs a webserver. You can install a local webserver on your computer, then you will be able to test your form locally. Note that a webserver in this context is not a hardware but a piece of software. WAMP is recommended often:

    https://sourceforge.net/projects/wampserver/
    3. Can I write a php in HTML? I tried with <?PHP ?> but doesn't seems to work, maybe because I need to install it.[/quote]&lt;?php
    // your PHP code here
    ?&gt;
    is correct however you will need a webserver where PHP is installed in order to run it.

    If you want to code a contact form it's highly recommended to use a library like PHPMailer. I know about a fine tutorial, for a contact form, but unfortunately it's in german.
    Copy linkTweet thisAlerts:
    @codyhillauthorJul 21.2019 — @Sempervivum#1606560 Thx! It's fine, shoot it! Hopefully will have a description
    Copy linkTweet thisAlerts:
    @MPMJul 26.2019 — Unless you have an interest in learning PHP I would suggest you NOT use it to do what you want. It is a powerful language and the concepts take a lot of effort to grasp because you have to mix so many things in. There must be many other ways to add a contact capability to your site which just involve pasting some code in.
    Copy linkTweet thisAlerts:
    @prasanttechizerJul 26.2019 — Do I need to install PHP in order for the PHP to work?

    I think you have developed your portfolio in PHP if it is correct then you can install the xampp then run your file with the .php like index.php. You can upload it online then hosing already install the php

    Is there any way I can find out if the contact form works before I upload it online?

    You can implement the form and implement the database to store the form value and implement the mail function then the contact form works correctly. If you have developed your portfolio in WordPress then you can just install a plugin contact form 7 then it is working.

    Can I write a PHP in HTML? I tried with <?PHP ?> but doesn't seems to work, maybe because I need to install it.

    No.you can not write the PHP in HTML. Because PHP is server-side language but HTML is client site language
    ×

    Success!

    Help @codyhill spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.25,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...