Afrihost hosting and feedback form

friedpiggy

Expert Member
Joined
Aug 6, 2005
Messages
1,709
Reaction score
1,273
Location
127.0.0.1
Greetings

Its been a while since I did anything web related, that said however I somehow was roped in to help a friend out with a site he is setting up. It doesn't look great yet, but he needed something up in a hurry so this is the result. The problem now is that he is wanting an application form on the site. Form done and then the problem starts.

It has been about 10 years since I last worked on a webform. So I check the Afrihost knowledgebase and according to that I need to use

<form method="post" action="http://www.afrihost.com/formmail.php">

Great stuff I think. I add that in as the start of the form and design a small form. test it on his hosting and I get

The requested URL /cgi-sys/formmail.cgi was not found on this server.

So I think to myself, I will chat to the Afrihost guys. No go. their live chat is offline.

Anyone have a clue where I am going wrong here?
 
The action has to point to the php file that is processing the form.


http://php.net/manual/en/tutorial.forms.php

you'll also need a submit button, <input type="submit">

Would you mind linking the page or posting the form code with the file names?


EDIT: a quick registration form that I did a while ago.
PHP:
<form method="Post" name="registerForm" action="register.php">
           <table class="table">
                    <tbody>
                        <tr>
                            <td>Username: </td>
                            <td><input type="text" placeholder="Enter username" name="username" required></td>
                        </tr>

                        <tr>
                            <td>Password: </td>
                            <td><input type="password" placeholder="Enter password" name="password" required></td>
                        </tr>

                        <tr>
                            <td>E-Mail: </td>
                            <td><input type="email" placeholder="Enter email" name="email" required></td>
                        </tr>

                        <tr>
                            <td colspan="2" style="padding-left:35%;"><input type="submit" value="Submit registration"></td>
                        </tr>
                    </tbody>
             </table>
   </form>
And the php file is called register.php
PHP:
 if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email'])){ //variables are set
        if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['email'])){ //variables aren't empty strings
            //we can now create the user account.
            $hash = password_hash($_POST['password'], PASSWORD_DEFAULT);

            include('dbConn.php');

            $sql = "INSERT INTO login (username, password, email, regdate)
                    VALUES ('{$_POST['username']}', '{$hash}' , '{$_POST['email']}', NOW())"; //note use of '' for literal

            try{
                if($conn->query($sql) === TRUE) {
                    jsAlert("Successful registration");
                } else {
                    jsAlert("User not added" . $conn->error);
                }
            } catch (Exception $e){
                jsAlert("Exception occurred: " . $conn->error);
            }

            $conn->close();
        }
    }

Above includes DB connection and insert. PHP 7

Probably missing best practice stuff, but I'm still new. At least the syntax is right and working. :D

Empty isn't required, I didn't realize that at the time, but I have a newer version of the above, so the above is me being more noobish than I am now. :D

Oh and the jsAlert function.
PHP:
function jsAlert($alertMsg){
        echo "<script type='text/javascript'>alert('$alertMsg');</script>";
    };

After googling your error for a bit, it's an issue with the script path, are you sure they installed it there? Or that it is configured?
 
Last edited:
Well thats the issue. unable to confirm with them that it is installed there, I can only go off of what is in the knowledgebase that has that path listed.
 
When browsing to the link pointing to the form, http://www.afrihost.com/formmail.php, you get the same cgi error.. either the script is broken, its no longer available or its been moved..

nothing new for afrihost to have broken hosting.. when you do manage to speak to their support department in a years time, you will probably end up getting the run around and not get a resolution..

build your own form or find a reliable example elsewhere..

see if this will work for you: http://www.freecontactform.com/email_form.php
 
Those formmail scripts have been removed from many cPanel servers for security reasons. Chances are they removed it but didn't bother to update the knowledgebase article. You would be better off downloading phpmailer and installing it on your account yourself.
 
Guys i have a similar problem with MWeb Hosting. My client's account does not support php. Is there a form-mailer in ASP/X?
 
Top
Sign up to the MyBroadband newsletter
X