dr4g 25 Junior Poster

Again, you need to validate your mail() command. By using @ or IF.

dr4g 25 Junior Poster

Taking the 'if' statement away from the mail functions worked :-)

The mail() function returns TRUE or FALSE upon sendin the email.
In order for you to write a decent script, you will have to verify that this mail was sent corrently.

Therefore you will need to wrap your mail() in an IF statement.
Otherwise your just firing an email out there and not getting any response back that it was successfull.

You can also do this to catch error messages instead of doing an if()

@mail(..);

The @ symbol would be an alternative to using the IF statement

dr4g 25 Junior Poster

The following is the necessary code to store, check that no info was empty and email the user.
You will need to change the $to variable to suit your needs.
You will also need to make <input name="form_from"> for the Text Box that stores the users email address
And the same need applied to the subject and message input boxes.

<?php
if(isset($_POST['your_submit_button_name_here'])) {


    $from = $_POST['form_from'];
    $subject = $_POST['form_message'];
    $message = $_POST['form_subject'];

    if(strlen($from) > 0 AND strlen($subject) > 0 AND strlen($message) > 0) {
        if(emailUser($from, $subject, $message))
            echo "Email Sent";
        else
            echo "Email Not Sent";
    }


    function emailUser ($from, $subject, $message) {
    
        $to = 'you@youremail.com';            
        $headers = "From: " . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
        return mail ($to, $subject, $message, $headers);
    }

} else {
?>


<!-- Do your HTML Here -->



<?php
}
?>

Cheers.
Enjoy.

dr4g 25 Junior Poster

You could use JavaScript Encode, to encode the HTML/page source, so that it isn't readable at all.

dr4g 25 Junior Poster

>Some comments might help the beginners Aia
Read the code with a C reference manual, step through it, and if you still have questions, ask them.

I understand the code, it was for the C beginners trying to understand the code (as there were 0 comments in his code)

dr4g 25 Junior Poster
/*
 * r_ascii.c
 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
#define MAX 126
#define MIN 33
 
int randy( int max, int min )
{
    int r_num;
    do
     {
        r_num = rand();
    }
    while ( r_num < min || r_num > max );
    return r_num;
}
 
int main( void )
{
    int i;
 
    srand( (unsigned) time( NULL ) );
 
 
     for( i = 0; i < 1000; i++ )
     {
        printf( "%c ", randy( MAX, MIN ) );
    }
    getchar();
    return 0;
}

Output:

b U * = ^ s y F c ; ^ x 5 v - k L 1 0 M r a n c w 4 o 5 w = : ' - 7 ? v ; L $ )
4 ? D I P r d y { D @ e p & O Y C L T % y f U h ( i F , p 8 D [ ^ < p W | V z |
2 : 1 * = 1 n q V & r F X { ] c ) > ] I O ? < < * ! U l W O ' h [ 1 g { x z % I
# R J L ) U : < ( % 9 + 6 S 8 q } , i . 8 O Z ; s D j i y W n o } P z ` i ^ i K
A 2 ] " 5 / = ( …
dr4g 25 Junior Poster

Just a Tip for you, as you're new to PHP.
Once you've written to the txt file and want to get all the info from it again.
You can use the file_get_contents() function to store the file's contents into a string.
Example:

$str = file_get_contents("file.txt");
echo $str;
 
Drag....
dr4g 25 Junior Poster
/* init */
     $arr = array(
                       "chapter1" => array(),
                       "chapter2" =>  array(),
                       "chapter3" => array()
      );

    $chapter1_amount = 4;
    $chapter2_amount = 6;
    $chapter3_amount = 8;

      for($i = 1; $i <= $chapter1_amount; $i++)
         array_push($arr['chapter1'], $i);

      for($i = 1; $i <= $chapter2_amount; $i++)
         array_push($arr['chapter2'], $i);  

      for($i = 1; $i <= $chapter3_amount; $i++)
         array_push($arr['chapter3'], $i);

This theoretically works. It's 3am and i didnt compile it, but looks fine to me.

For manipulating the link acording to the dropdown list.
You'd need to call a javascript function to generate the link.
When you choose an option in the list, you'd call the javascript function to update the link.

/* HTML */
      <select onChange="updateLink(this)">....</select>

      /* JavaScript */
     function updateLink(list) {
        if(list.value='bleh')
            link = "bleh";

       ......
  
       return link;

     }
dr4g 25 Junior Poster

Another solution would be, instead of using a foreach() you could use a for() loop.

$arr = array("cat", "dog", "horse", "frog");
 
echo "<select name=dropdown_list><option value="bleh">Choose Me</option>";
 
// loop while $i is less than count(the amout of elements) of $arr
for($i=0; $i < count($arr); $i++)
   echo <option value=". $arr[$i] .">" . $arr[$i] . "</option>";
 
echo "</select>";

Enjoy.