Hi. I just finally learned how to get the include or require command to work - for me, anyway: by calling variables in an .inc file with the print command. That's all I know about PHP.

I have a list of people's names - including mine - on a page, with links to contact forms. And I want to switch from thesitewizard's script to Asoft's AContact Form, 'cause I'm tired of getting spammed from these forms - I'm sure the others on the list are too. (thesitewizard's script prevents address harvesting, but not bot spamming from web forms - Asoft's does.)

What I'd like to know is, is it possible - without a database - to add each name to each contact link - or something like that - to tell the contact form to print it on the page as the title and heading "Contact (name)", and to print each email address from the .inc file to the config file so I can use just one contact form? Or will I have to create a config file and contact form for each person (as I did for thesitewizard's script) with its own unique print command?

I have a MySQL database for my Viper guestbook 'cause the script created the database. But I don't know the first thing about MySQL. I'd really rather not have to learn it if there's another option.

    Well, if I understand right what you need is to use one form to send emails to different people....

    You could put names into the .inc file, into an array like that:

    $contacts[0]['name'] = 'Me';
    $contacts[0]['email'] = 'my@email.com';
    
    $contacts[1]['name'] = 'Friend';
    $contacts[1]['email'] = 'friend@email.com';

    Then to call the form with a parameter, corresponding to the position of the desired person in the array, so for my friend should be like that emailer.php?person=1

    Then when needed, just use $contacts[$_GET["person"]][...]
    This way you can keep much more information than just email and name.

    Hope that helped,

      Hope that helped

      Huh. It just may have. Ok. So how exactly do I set it up for:

      1) printing / displaying the person's name in the form heading? You didn't say how to do that, did you?

      <h1>Contact (what exactly do I put here?)</h1>

      2) getting the person's e-mail address from the .inc file through the contact URL in a secure way so someone can't take the address in the process?

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

      b) Do I use the actual word "person"? Or do I need to substitute "person" with each person's variable number (the 1 in $contacts[1]) or something else?

      c) The form script has:

      mail("$receiver", $subject, $messageproper, "From: $yoursitename <$email>");

      The "receiver" variable gets the email address from the config file. Do I change "receiver" to "contacts" and put:

      [$_GET["person"]];

      just after:

      $contacts

      ?

      d) How do I tell the form which variable to get and insert there? Whether the name or the email address? Just the "person" variable doesn't seem specific enough.

      e) Do I have to create an if / else rule to get one or both of these to work? If so, what exactly?

        6 days later

        Since noone answered the questions in my 2nd post, I tried getting 'em answered at another site, and got a vague answer with a couple bits of code. So I still have some questions I need answers to and thought I'd try this forum again. Here they are, with quotes from the person that replied.

        If the .inc file is displayed in HTML to the user, then they will be able to parse the webpage for the information.

        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?

        Not the exact because I am unsure how your arrays are set up in the first place.

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

        Do you mean should you define the array before filling it in? Sure. $myArray = array();

        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?

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

        Where does the following code go? In the .inc file or the PHP form file? The person who replied 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?

        // 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;
        }
        

        I assume the following code goes in the PHP contact form file? Where exactly? If you don't have AContact Form, could you please download 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?

        // 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]);
        
        }
        

        The person who replied says 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.

        Use this one:

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

        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?

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

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

        (though I put my varibles into something and try not to use the $_GET over and over)

        Does the code the person 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.

          Write a Reply...