Reply
Creating a form with PHP
Old 07-10-2004, 01:03 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Okay, I think I have my head around it now

Right, first up change if($contactname != "") back to just that. What this is saying is if the contact name sent through to the script from the form is not empty, continue with the process - putting your email address in there will actually cause the script not to run properly.

Secondly, what is your database table called? I believe the reason the fetch_array part isn't working is because the script is querying a table that doesn't exist.
PHP Code:
//CHANGE THIS
$query "SELECT email FROM contacts WHERE (property_id = '$property')";

//TO THIS
$query "SELECT email FROM yourtablename WHERE (property_id = '$property')";

//AND THEN CHANGE THIS
$resultmysql_db_query($dbname$query$link); 

//TO THIS
$resultmysql_db_query($dbname$query$link) OR die("<font color=red>Result Error : </font>" .mysql_error()); 
In the first change, contacts becomes whatever you have called the table in which your data is stored. The fact that your table now contains more columns is not relevant to this script so long as the email column is called email, which it seems to be.

The second change puts in some error reporting functionality that will describe the error as opposed to just giving you warning that it isn't working.

Any more problems, post back or message/e-mail me your code and database structure and I will see what I can do

Regards

Ian.
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 07-10-2004, 01:33 PM
Veter's Avatar
Super Talker

Posts: 136
Sorry, maybe I've missed something, but what are you trying to do?

You want to make the database for 7 rows?

Much easier will be use array for that. No need to use database at all.

PHP Code:
$emails = array ("1st@email.com","2nd@email.com",
"3rd@email.com","4th@email.com"); 
In your form, for "Property Type:" use values like 1,2,3, etc.

and in the email script just do:
PHP Code:
$toaddress "$emails[$property]";

mail($toaddress$subject$message$headers); 
Thats much simpler and dont need to use mysql for that.

If you need full version of the script for that, let me know.
It could be done for 5 min
__________________
-= B2Netsolutions Inc. =-
-= Dedicated servers - Shoutcast hosting =-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-10-2004, 01:35 PM
andrewsco's Avatar
Super Talker

Posts: 130
Thanks!!! The problem was not actaully what I thought it was I had (stupidly mispelt one of the names!) Just one final question though if its ok. I managed to recieve the email through, (i sent it to me) but could have sent it to anyone. What I would like is some type of header that cant be deleted saying that this interest has come from Shore2sure.com, so that they know that we got them the interest. But also We would like an email as well so we can monitor how much interest the site is getting.

How would I go about doing this?

Thank you so much for all your help

Andy
__________________
My Webpage: www.computer-tutorials.org
andrewsco is offline
Reply With Quote
View Public Profile Visit andrewsco's homepage!
 
Old 07-10-2004, 01:38 PM
andrewsco's Avatar
Super Talker

Posts: 130
Thanks veter, but iv managed to get it working, and as someone mentioned below I would like eventually to get more stuff linked to the database and perhaps allow people who want properties on our site to do it thierselves and it would go straight through an online form, to save us having to create new pages all the time. But thats not going to happen for a while, as I am still new to all this really

Thanks

Andy
__________________
My Webpage: www.computer-tutorials.org
andrewsco is offline
Reply With Quote
View Public Profile Visit andrewsco's homepage!
 
Old 07-10-2004, 01:39 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Hi Veter,

I'm sure there are a lot more than just seven rows. I believe Andrew has over 100 properties on his list and is likely to be adding to them all the time, therefore a database is the most logical solution. If you used an array in this instance, it would be huge and there would be a constant need to keep updating the script.

Far easier to update a database I feel.

Regards

Ian
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 07-10-2004, 01:47 PM
Veter's Avatar
Super Talker

Posts: 136
Yes, in this case I agree with you

I've just missed that it will be updated regulary.
__________________
-= B2Netsolutions Inc. =-
-= Dedicated servers - Shoutcast hosting =-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-10-2004, 01:49 PM
andrewsco's Avatar
Super Talker

Posts: 130
Just one final question though if its ok. I managed to recieve the email through, (i sent it to me) but could have sent it to anyone. What I would like is some type of header that cant be deleted saying that this interest has come from Shore2sure.com, so that they know that we got them the interest. But also We would like an email as well so we can monitor how much interest the site is getting.

How would I go about doing this?

Thank you so much for all your help

Andy
__________________
My Webpage: www.computer-tutorials.org
andrewsco is offline
Reply With Quote
View Public Profile Visit andrewsco's homepage!
 
Old 07-10-2004, 01:50 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Great news Andy,

Okay for the last bit try this: -
PHP Code:
//CHANGE THIS
//return the result but don't print it to the webpage 

while ($row=mysql_fetch_array($result)) { 

$MailTo "$row[email]"



//TO THIS (ADDS YOUR E-MAIL ADDRESS)
//return the result but don't print it to the webpage 

while ($row=mysql_fetch_array($result)) { 

$MailTo "$row[email],admin@shore2sure.com"



//Now to add the subject header that cannot be removed

$Subject "Contact from shore2sure.com - $Subject";

//the rest of the script appears below this as normal 
I think that should do it
Regards
Ian
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 07-10-2004, 01:53 PM
Veter's Avatar
Super Talker

Posts: 136
PHP Code:
$headers "From: Your info<yourform@emai.com>\n";
    
$headers .= "X-Sender: <yourform@emai.com>\n";
    
$headers .= "Mime-Version: 1.0\n";
    
$headers .= "Content-Type: text/html\n";
    
$headers .= "Content-Transfer-Encoding: 
quoted-printable\n"
;
    
$headers .= "X-Mailer: PHP\n";
    
$headers .= "Cc: <yourl@emai.com>"
Cc: will send copy to your email.
__________________
-= B2Netsolutions Inc. =-
-= Dedicated servers - Shoutcast hosting =-

Last edited by Veter : 07-10-2004 at 01:58 PM.
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-10-2004, 02:03 PM
andrewsco's Avatar
Super Talker

Posts: 130
thanks guys...I got there in the end.

Thanks again for all the help

Andy
__________________
My Webpage: www.computer-tutorials.org
andrewsco is offline
Reply With Quote
View Public Profile Visit andrewsco's homepage!
 
Reply     « Reply to Creating a form with PHP

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 5.15528 seconds with 11 queries