PHP Code i need help in editing it please

Discussion in 'PHP' started by mohamedselim, Mar 17, 2011.

  1. #1
    well i have a PHP code which i dont know how to edit it as the way i want , it is working that way but not like i want it have some errors or so i need to be fixed and want to add some stuff to it too

    here is the code :

    <?php
    //--------------------------Set these paramaters--------------------------

    // Subject of email sent to you.
    $subject = 'Results from Customer Comments';

    // Your email address. This is where the form information will be sent.
    $emailadd = 'email@.com';

    // Where to redirect after form is processed.
    $url = 'http://mythankyoupage';

    // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
    $req = '1';

    // ----------------------------------------------------
    $text = "Results from form:\n\n";
    $space = ' ';
    $line = '
    ';
    foreach ($_POST as $key => $value)
    {
    if ($req == '1')
    {
    if ($value == '')
    {echo "$key is empty";die;}
    }
    $j = strlen($key);
    if ($j >= 20)
    {echo "Name of form element $key cannot be longer than 20 characters";die;}
    $j = 20 - $j;
    for ($i = 1; $i <= $j; $i++)
    {$space .= ' ';}
    $value = str_replace('\n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    $space = ' ';
    }
    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    ?>

    so this code is already working as i refereed before
    in my webpage the customer comments i have
    First Name , Last Name , Email and Comments Fields and submit ( to send those comments to my email ) and reset ( to clear all the data that the customer entered and start over again ) buttons

    so when i test the code , if i fill all the fields it direct me to my thank you page so this is the only working part.

    when i leave any field empty or all of them empty it automatic redirect me to a page i didnt create saying that this field is empty , but it still send the email to me with the empty fields.

    so what i want is if i leave any field empty there is an error pages i created to each field saying that this field is empty , and having the logo of the website and stuff like that and that this customer need to go back which there is a link in the page already created to go back to the customer comments page.
    and to send automatic email to the customer that i will be in touch with asap
    and to add an image verification ( to control the spam ) if that is possible but actually i dont know how to do it yet..

    hope this was clear this time , thanks for your time appreciate any help.
     
    mohamedselim, Mar 17, 2011 IP
  2. artus.systems

    artus.systems Well-Known Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #2
    artus.systems, Mar 17, 2011 IP