Jump to content

Archived

This topic is now archived and is closed to further replies.

brent65

How to Set Up a Contact Form Array (Newbie)

Recommended Posts

Hi. I have a list of people's names on a page, with links to contact forms using thesitewizard's script. I'm a newbie and need to know exactly how to set it up so all the contact links use the same contact form using ASoft's AContact Form script, without using a database.

I was told I need to have the form get each person's name and email address from an .inc file which has this array:

[code]$person[0]['name'] = 'Name';
$person[0]['email'] = 'name@address.com';

$person[1]['name'] = 'Name';
$person[1]['email'] = 'name@address.com';[/code]

I was also told I need to put a parameter in each contact link, like this: (contact.php?person=1) Is that right? If so, I have some more questions that aren't getting answered in the forum I posted them on (on another site). Hopefully I'll have better luck here.

1) Can a spam bot harvest the email address with this method, when the form is getting it from the .inc file?

2) Do I have to have an array command above / before the variables in the .inc file? If so, what exactly?

3) Is the 1 in the person=1 parameter in the URL referring to the 1 in the person[1] variable in the .inc file?

4) I want that parameter to tell the contact form to print the person's name on the page as the title and heading "Contact (name)" and was told I need to use the $_GET command. Which one of the following codes is right? (The 1 refers to the 1 in the person=1 parameter in the URL, which refers to the 1 in the person[1] variable in the .inc file.)

[code]<h1>Contact echo $person[$_GET["1"]["name"]];</h1>[/code]

[code]<h1>Contact <? print($person[$_GET["1"]["name"]]); ?></h1>[/code]

5) ASoft's form script has: [code]mail("$receiver", $subject, $messageproper, "From: $yoursitename <$email>");[/code]

The "receiver" variable gets the email address from the config file, which I'll be replacing with an .inc file. Do I need to replace $receiver with: [code]$person[$_GET["1"]["email"]];[/code] with the 1 referring to the 1 in the person=1 parameter in the URL, which refers to the 1 in the person[1] variable in the .inc file?

6) Do I have to create an if / else rule to get one or both of these (printing name and getting email address) to work? If so, what exactly?

Share this post


Link to post
Share on other sites
[!--quoteo(post=386621:date=Jun 21 2006, 03:44 PM:name=Brent)--][div class=\'quotetop\']QUOTE(Brent @ Jun 21 2006, 03:44 PM) [snapback]386621[/snapback][/div][div class=\'quotemain\'][!--quotec--]


1) Can a spam bot harvest the email address with this method, when the form is getting it from the .inc file?
[/quote]
Spam bots usually are designed to go through the HTML of a document. If the .inc file is displayed in HTML to the user, then they will be able to parse the webpage for the information. They can only get what you can see when you 'view source'

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
2) Do I have to have an array command above / before the variables in the .inc file? If so, what exactly?
[/quote]
Do you mean should you define the array before filling it in? Sure. $myArray = array();

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
3) Is the 1 in the person=1 parameter in the URL referring to the 1 in the person[1] variable in the .inc file?
[/quote]
It can if its designed that way. Though with php array's are zero based. So they start like myArray[0], myArray[1], myArray[2]....

But if you are trying to pull the value from the URL, I do believe you are doing it correctly.

[code]
// URL looks like http://mysite.com/page.php?person=1

//Check to see if the variable is set
if (isset($_GET['person'])) {
   // Grab the value
   $value = $_GET['person']

   // Get that particular item from the array and spill its contents
   print_r($myArray[$person]);

}
[/code]
[code]
4) I want that parameter to tell the contact form to print the person's name on the page as the title and heading "Contact (name)" and was told I need to use the $_GET command. Which one of the following codes is right? (The 1 refers to the 1 in the person=1 parameter in the URL, which refers to the 1 in the person[1] variable in the .inc file.)
[/quote]

Use this one (though I put my varibles into something and try not to use the $_GET over and over):
[code]<h1>Contact <? print($person[$_GET["1"]["name"]]); ?></h1>[/code]
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]

5) ASoft's form script has: [code]mail("$receiver", $subject, $messageproper, "From: $yoursitename <$email>");[/code]

The "receiver" variable gets the email address from the config file, which I'll be replacing with an .inc file. Do I need to replace $receiver with: [code]$person[$_GET["1"]["email"]];[/code] with the 1 referring to the 1 in the person=1 parameter in the URL, which refers to the 1 in the person[1] variable in the .inc file?
[/quote]

I believe that is right, but take the quotes out around the 1 ($_GET[1])

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
6) Do I have to create an if / else rule to get one or both of these (printing name and getting email address) to work? If so, what exactly?
[/quote]

Should have to. You could loop through your 2dimensional array sorta like:

[code]
// Go through the top most array
foreach($myArray as $something => $miniArray) {
  // Now I can pull the information I want from the inner arrays
  $name = $miniArray[0];
  $email = $miniArray[1];
  next;
}
[/code]
I think that should give you a rough idea. Not the exact because I am unsure how your arrays are set up in the first place. Hopefully this helps you, if not I can try and further explain....

:)

Share this post


Link to post
Share on other sites
Hmm. I thought I posted this yesterday. Oh well. I'll try again.

[!--quoteo(post=386632:date=Jun 21 2006, 06:01 PM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Jun 21 2006, 06:01 PM) [snapback]386632[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hopefully this helps you, if not I can try and further explain....[/quote]

Yeah, it helps me. Thanks. Being a newbie, though, explaining further will help even more!

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]If the .inc file is displayed in HTML to the user, then they will be able to parse the webpage for the information.[/quote]

Ok. Well, both the thesitewizard and AContact scripts store the email address in a PHP file, which thesitewizard claims is inaccessible to bots. But I was wondering if storing the address in an .inc file would make it accessible to bots, either by being in an .inc file as opposed to a PHP file - even though the .inc file starts with <?php and ends with ?>, or when being retrieved from it by the PHP contact form. I don't how PHP works, but it won't be displayed in HTML, will it, with the php contact form getting the email address from the .inc file?

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Not the exact because I am unsure how your arrays are set up in the first place.[/quote]

I haven't set 'em up yet, 'cause I don't know how. That's why I asked those questions and am asking more.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Do you mean should you define the array before filling it in? Sure. $myArray = array();[/quote]

Yesterday I learned there are two different ways to write the array I'm using. One's like that, with the variables in between the parentheses separated by a =>, and the other like the following code I was given. So correct me if I'm wrong, but it appears I would only use the $myArray code to define the array if I was writing it that way. But if I write it the other way, the following should be all the code I need in the .inc file, right?

[code]
<?php
$person[0]['name'] = 'Name';
$person[0]['email'] = 'name@address.com';

$person[1]['name'] = 'Name';
$person[1]['email'] = 'name@address.com';
?>[/code]

Where does the following code go? In the .inc file or the PHP form file? You didn't say. And where exactly in the file? If in the .inc file, before the code I posted above, instead of it? Or where?

[code]
// Go through the top most array
foreach($myArray as $something => $miniArray) {
  // Now I can pull the information I want from the inner arrays
  $name = $miniArray[0];
  $email = $miniArray[1];
  next;
}
[/code]

I assume the following code goes in the PHP contact form file? Where exactly? If you don't have AContact Form, could you please [a href=\"http://www.chocoboheaven.com/asoft/page.php?id=4\" target=\"_blank\"]download[/a] it and look at the contact.php file to see where the code should go? 'Cause the code for it would take up quite a bit of space here. Or should I post it anyway?

[code]
// URL looks like http://mysite.com/page.php?person=0

//Check to see if the variable is set
if (isset($_GET['person'])) {
   // Grab the value
   $value = $_GET['person']

   // Get that particular item from the array and spill its contents
   print_r($myArray[$person]);

}
[/code]

You say it spills it's contents, but I don't want it to print / display the email address. Just the person's name. With that code and the php?person=0 query string, how does the form know to get and print that person's name instead of the email address? I would think I'd have to include ["name"] somewhere in the code, like in the following code.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Use this one: [code]<h1>Contact <? print($person[$_GET["1"]["name"]]); ?></h1>[/code][/quote]

Ok. Well I didn't realize it at the time, but that code will only work for person 1's name, huh? In other words, I'd only be able to use the form for that one person. If I get rid of ["1"] or as you said [1] would it be correct? Like this?

[code]<h1>Contact <? print($person[$_GET["name"]]); ?></h1>[/code]

Or do I need to use the isset / print_r code above instead?

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--](though I put my varibles into something and try not to use the $_GET over and over)[/quote]

Does the code you posted show that? If not, what does the code look like for that in the .inc file? And what does it look like in the PHP file for both printing the name and getting the email address? If you could list all the code I need to add to the PHP file, and all the code I need to put in the .inc file, that'd be great. But if you feel that's going too far, I'll just keep asking questions until I hopefully get this straight.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.