Jump to content

budimir

Members
  • Posts

    522
  • Joined

  • Last visited

Posts posted by budimir

  1. OK, that is quite simple.

     

    You can use PHP mail() function to send emails.

     

    $to = "email@example.com"; //Here goes $_POST["email"];
    $subject = "Test mail"; //Here goes some subject like "This is enqur. from web page"
    $message = "Hello! This is a simple email message."; //Here goes like phone number etc.
    $from = "someonelse@example.com";
    $headers = "From: $from"; //Here goes you're email adress
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    

     

    Also, DarkWater is right, go get new book. This is just causing problems for you.

  2. Well, now he will have much clearer picture of how to store data in a DB. I don't see any point in just displaying the values on the form.

     

    If he is learning then I showed him much bigger picture and made the situation more understandable for him.

     

    And, I'm sorry guys, but if he is learning PHP, then it's much better that he learns how to create a database and establish a link to it, first. Then he can start learning PHP.

     

    It's like a building a house from the roof.

  3. You are not trying to get the values from form.

     

    $1 = $_POST["name"];
    $2 = $_POST["email"];
    $3 = $_POST["company"];
    $4 = $_POST["number"];
    

     

    and then query to insert into DB

     

    $sql = "INSERT INTO table_name (name_of_fields) VALUES ($variables)";
    $result = mysql_query($sql) or die (mysql_error());

     

    That's basiclly all the code you need to insert data in DB. just adjust it according to your needs and to match your DB fields.

     

    P.S.

    You know that you need a connection to DB??

  4. OK, I'm trying to rework this a little bit and I need your help. My knowledge of javascript is not to good.

     

    This is what I have for now:

     

    <SCRIPT LANGUAGE="JavaScript">
    <!-- 	
    // by Nannette Thacker
    // http://www.shiningstar.net
    // This script checks and unchecks boxes on a form
    // Checks and unchecks unlimited number in the group...
    // Pass the Checkbox group name...
    // call buttons as so:
    // <input type=button name="CheckAll"   value="Check All"
    //onClick="checkAll(document.myform.list)">
    // <input type=button name="UnCheckAll" value="Uncheck All"
    //onClick="uncheckAll(document.myform.list)">
    // -->
    
    <!-- Begin
    function checkAll(field)
    {
    for (i = 0; i < field.length; i++)
    field[i].selected = true ;      ------ I have changed this from "checked" to "selected"
    }
    
    function uncheckAll(field)
    {
    for (i = 0; i < field.length; i++)
    field[i].selected = false ;
    }
    //  End -->
    </script>

     

    And for the event I have done this:

     

    onChange="checkAll(document.autoSumForm.list)

     

    Couple of questions:

     

    1. Is this possible?

    2. document.autoSumForm.list -> list is a name of object on a form, is it possible to use ID instead of name????

  5. Hey guys,

     

    Do you know of anyscript where user could choose a value in select box and then automaticlly 3 or more other select boxes would get the same value?

     

    For instance:

    User chooses in selectbox 1 value car

    And the automaticly selectbox2 gets value car

    And the automaticly selectbox3 gets value car

    And the automaticly selectbox4 gets value car

    And the automaticly selectbox5 gets value car

    And the automaticly selectbox6 gets value car

     

    Or you can point what to search on google!

  6. Here is a suggestion.

     

    It would be nice to put a small icon next to the topic title for "Topic solved" on the forum index. It would be more visible and easier to access for a user that posted a topic to click that icon and mark topic as solved.

     

    Right now, there is a lot users that don't click "Topic solved" and I think this could reduce number of those users.

     

    Cheers.

  7. Here is a suggestion.

     

    It would be nice to put a small icon next to the topic title for "Topic solved" on the forum index. It would be more visible and easier to access for a user that posted a topic to click that icon and mark topic as solved.

     

    Right now, there is a lot users that don't click "Topic solved" and I think this could reduce number of those users.

     

    Cheers.

  8. Here it is:

     

    ID  From        To        Distance

    1    Zagreb    Karlovac  52Km

    2    Zagreb    Knin        274Km

    3    Zagreb    Virovitica 154Km

    4    Zagreb    Split        374Km

    5    Karlovac  Pula        234Km

     

    These are values from DB.

     

    I'm not sure how to calculate distance (for example) from Karlovac to Knin??? And other combinations??

  9. OK, maybe you can do this:

     

    $query = mysql_query("SELECT email FROM users WHERE email = '".$email."'");
    while($row=mysql_fetch_array($query)){
    $email1 = $row["email"];
    }
    
    if ($email1 == $email){
          if(@mysql_query($query)) $erroremail = true;
          
                $query2 = "INSERT INTO users SET
                   username='$username',
                   password='$password',
                   email='$email'";

    } else {

    echo "Data is already in DB!";

    }

    [/code]

     

    Here is antoher check, where we will check if that email is already stored in DB and if it is it will display an error message. Maybe you will need to adjust a code a litlle bit.

  10. Hey guys,

     

    I'm creating a script where I should display distances between two cities. User can choose From - To cities and then distance is displayed

     

    For example:

     

    City 1    ->    City2    = 56km

    City55    ->  City72  = 110km

    ...

     

    In my DB I have this fields:

    ID

    date

    from_city

    to_city

    distance

     

    How do I calculate which is distance from one city to another???

     

  11. @iversonm:

     

    $a != $b  Not equal  TRUE if $a is not equal to $b.

    $a !== $b  Not identical  TRUE if $a is not equal to $b, or they are not of the same type. (introduced in PHP 4)

     

    In both cases he will get the same result in his if function, because it's the same type.

     

    Although, as looking now if

    $_SESSION['token'] = uniqid(md5(microtime()), true);

    is encoded with md5. Then

    if ($_GET['token'] != $_SESSION['token']) 

    is always FALSE unless decoded.

     

    @lanmind:

     

    Where do you get

    $_SESSION['token']

    for your if statment

    if ($_GET['token'] != $_SESSION['token'])

    ?

  12. You already did it, but in a wrong order!

     

    Here is a fix:

     

    <?php
    include 'db.php';
    include 'function.php'; 
    
    if($_POST['register']) { 
    
       
       //init error variables
       $errorusername = false;
       $erroremail = false;
       $erroremailconf = false;
       $errorpassword = false;
       $errorpassconf = false;
       
       $username = isset($_POST['username']) ? trim($_POST['username']) : '';
       $email = isset($_POST['email']) ? trim($_POST['email']) : '';
       $emailconf = isset($_POST['emailconf']) ? trim($_POST['emailconf']) : '';
       $password = isset($_POST['password']) ? trim($_POST['password']) : '';
       $passconf = isset($_POST['passconf']) ? trim($_POST['passconf']) : '';
       
       if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $erroremail = true;
       if(strlen($username) == '0') $errorusername = true;
       if(strlen($emailconf) == '0') $erroremailconf = true;
       if(strlen($password) == '0') $errorpassword = true;
       if(strlen($passconf) =='0') $errorpassconf = true;
       
       //display form again
       if($errorusername || $erroremail || $erroremailconf || $errorpassword || $errorpassconf) {
          showForm($errorusername,$erroremail,$erroremailconf,$errorpassword,$errorpassconf);
       
       } else {
          
          //check user email
          
          $query = mysql_query("SELECT email FROM users WHERE email = '".$email."'");
          if(@mysql_query($query)) $erroremail = true;
          
                $query2 = "INSERT INTO users SET
                   username='$username',
                   password='$password',
                   email='$email'";
                   
                   
          if(@mysql_query($query2)) {
             echo 'Signup Completed';
             }else{
                echo 'failed to signup';
                }   
               
          }
    
    } else {
    
    echo "Nothing happens!"; //Leave this empty, I just putted it for test
    
    }
    ?>

×
×
  • Create New...

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.