PHP Form Processing

PHP coding talk.

Moderator: Moderators

PHP Form Processing

Postby Mikey Bee on Fri Jul 28, 2006 3:12 pm

I've been doing some work on a website for a friend and had included a contact form on the site for them. I was using an old script I had knocking around to process the form. Everything was fine and dandy until he said he wants the ability to upload files with the form. Aaaagh!!

Can anyone recommend a site which has free web form handlers with this option? I've had a look around and can't find any.

Your help on this would be gratefully received.

Cheers,

MB
Mikey Bee
Registered User
Registered User
 
Posts: 61
Joined: Tue Jan 31, 2006 10:54 am

Postby DooBDee on Fri Jul 28, 2006 7:18 pm

Take a look at $_FILES in php manual ;)
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Postby Splinter on Fri Jul 28, 2006 9:10 pm

Or if you don't want to do it the hard way then try:

http://www.hotscripts.com/PHP/Scripts_and_Programs/Form_Processors/index.html

Regards.
User avatar
Splinter
Coder
Coder
 
Posts: 483
Joined: Sun Feb 20, 2005 10:12 pm
Location: Nottingham, UK

Postby UseLess on Fri Jul 28, 2006 10:44 pm

Greetings,

In my experience solving a problem yourself is a lot more rewarding than having to copy and paste code someone else has written. However reading this: http://uk2.php.net/features.file-upload will give you all the information you need along with examples.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby Mikey Bee on Sun Jul 30, 2006 11:02 am

Cheers guys. Appreciate the help :)
Mikey Bee
Registered User
Registered User
 
Posts: 61
Joined: Tue Jan 31, 2006 10:54 am

Postby internetbrother on Thu Nov 09, 2006 6:58 pm

internetbrother
Registered User
Registered User
 
Posts: 252
Joined: Sat Oct 15, 2005 10:36 am

Postby Mikey Bee on Thu Nov 09, 2006 8:03 pm

[quote user="internetbrother" post="84098"]have you tried any one here

http://www.hotscripts.com/PHP/Scripts_a ... index.html[/quote]

I ended up using aFormMail as it did the job but thanks for the heads up on these other resources. Will bookmark and come back to them if I need an alternative.
Mikey Bee
Registered User
Registered User
 
Posts: 61
Joined: Tue Jan 31, 2006 10:54 am

Postby internetbrother on Fri Nov 10, 2006 5:03 am

any body can tell me what is wrong with this?
Code: Select all
<?
$to="myemail@mydomain.com";
$subject="form";
$contents="Name : $Name \nCompany : $Company \nFax : $Fax \nCountry : $Country \nInquiry : $Inquiry ";
mail($to,$subject,$contents);
?>


and this the form

Code: Select all
<form action="inquiry.php" method="post" name="" id="">
              <table width="100%" border="2">
                <tr bgcolor="#DEDDED">
                  <td width="22%"><div align="center">Name</div></td>
                  <td width="78%"><div align="center">
                    <label>
                    <input name="Name" type="text" id="Name" size="20">
                    </label>
                  </div></td>
                </tr>
                <tr bgcolor="#DEDDED">
                  <td><div align="center">Company's Name </div></td>
                  <td><div align="center">
                    <label>
                    <input name="Company" type="text" id="Company" size="20">
                    </label>
                  </div></td>
                </tr>
                <tr bgcolor="#AEBCB4">
                  <td><div align="center">Telephone Number </div></td>
                  <td><div align="center">
                    <label>
                    <input name="Telephone" type="text" id="Telephone" size="20">
                    </label>
                  </div></td>
                </tr>
                <tr bgcolor="#AEBCB4">
                  <td><div align="center">Fax Number </div></td>
                  <td><div align="center">
                    <label>
                    <input name="Fax" type="text" id="Fax" size="20">
                    </label>
                  </div></td>
                </tr>
                <tr bgcolor="#DEDDED">
                  <td><div align="center">Email Address </div></td>
                  <td><div align="center">
                    <label>
                    <input name="Email" type="text" id="Email" size="20">
                    </label>
                  </div></td>
                </tr>
                <tr bgcolor="#DEDDED">
                  <td><div align="center">Country</div></td>
                  <td><div align="center">
                    <label>
                    <input name="Country" type="text" id="Country" size="20">
                    </label>
                  </div></td>
                </tr>
                <tr bgcolor="#AEBCB4">
                  <td><div align="center">Your Inquiry </div></td>
                  <td><div align="center">
                    <label>
                    <textarea name="Inquiry" cols="50%" rows="10" id="Inquiry"></textarea>
                    </label>
                  </div></td>
                </tr>
                <tr bgcolor="#AEBCB4">
                  <td colspan="2"><div align="center">
                    <label>
                    <input type="submit" name="Submit" value="Submit your inquiry online">
                    </label>
                  </div></td>
                </tr>
              </table>
            </form>


I tried many times but does not work
internetbrother
Registered User
Registered User
 
Posts: 252
Joined: Sat Oct 15, 2005 10:36 am

Postby internetbrother on Sat Nov 11, 2006 4:37 am

I still can not figure it out
internetbrother
Registered User
Registered User
 
Posts: 252
Joined: Sat Oct 15, 2005 10:36 am

Postby Splinter on Sat Nov 11, 2006 4:58 am

Hi,

Does it come up with any errors?
User avatar
Splinter
Coder
Coder
 
Posts: 483
Joined: Sun Feb 20, 2005 10:12 pm
Location: Nottingham, UK

Postby UseLess on Sat Nov 11, 2006 10:07 am

Greetings,

'register globals' is probably turned 'off' on the server, therefore you will have to extract the form variables/values yourself.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby internetbrother on Sat Nov 11, 2006 1:17 pm

the same server has other forms too and similary with not problem

OK this is what I get: the form is successfully deliverd but all it has is

Name:
Email:
bla bla:
with no date just empty :roll: very strange
this must not be so complicated but do have any idea why!
internetbrother
Registered User
Registered User
 
Posts: 252
Joined: Sat Oct 15, 2005 10:36 am

Postby UseLess on Sat Nov 11, 2006 1:35 pm

Greetings,

As previously stated, 'register globals' may be turned off on the server, therefore any variables in the POST and GET arrays will NOT be turned into variables. Therefore all the variables your using on line 4 such as '$Name' will be empty.

Therefore you should extract the values yourself using something like;
Code: Select all
$Name = (isset($HTTP_POST_VARS['Name']) ? $HTTP_POST_VARS['Name'] : '');

and the same for the other variables.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby internetbrother on Sat Nov 11, 2006 3:49 pm

thanks I will give it another try
to the code must be like this?

Code: Select all
<? 
$to="myemail@mydomain.com"; 
$subject="form"; 
$Name = (isset($HTTP_POST_VARS['Name']) ? $HTTP_POST_VARS['Name'] : '');
$Company = (isset($HTTP_POST_VARS['Company']) ? $HTTP_POST_VARS['Company'] : '');
$Fax = (isset($HTTP_POST_VARS['Fax']) ? $HTTP_POST_VARS['Fax'] : '');
$Country = (isset($HTTP_POST_VARS['Country']) ? $HTTP_POST_VARS['Country'] : '');
$Inquiry = (isset($HTTP_POST_VARS['Inquiry']) ? $HTTP_POST_VARS['Inquiry'] : '');
 
mail($to,$subject,$Name,$Company,$Fax,$Country,$Inquiry); 
?>
internetbrother
Registered User
Registered User
 
Posts: 252
Joined: Sat Oct 15, 2005 10:36 am

Postby internetbrother on Sat Nov 11, 2006 4:06 pm

:oops:
internetbrother
Registered User
Registered User
 
Posts: 252
Joined: Sat Oct 15, 2005 10:36 am

Next

Return to PHP Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron