Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. you need to define $line before you use it first.


    [code]

    <html>
    <head>
    <title>Mailing Data From a File</title>
    </head>
    <body>
    <?php
    $line = file("Grades.txt");
    $i = 0;
    $num = 0;
    $cnt = 0;
    while ($line[$i] != -2) {
          $first = $line[$i];
          $i++;
          $last = $line[$i];
          $i++;
      while ($line[$i] != -1) {
            $num = $num + $line[$i];
            $cnt++;
            $i++;
            }
    $num = $cnt > 0 ? $num / $cnt : 0;
    echo "$last, $first, $num
    ";
    $i++;
    $cnt = 0;
    $num = 0;
    }
    ?>
    <?php
    $email = $_POST[user_email];
    $to = "$email";
    $subject = "Grades";
    $headers = "From: The PHP Master <youremail>";
    mail($to, $subject, $line, $headers);
    ?>
    </body>
    </html>

    [/code]
  2. [code]
    <?php
    $connection = mysql_connect(host,dbuser,dbpass);
    $db = mysql_select_db(dbname,$connection);
    $sql = "SELECT * FROM dbtable1 WHERE dbtable1.id=$_GET[id];";
    $result = mysql_query($sql);
    $sql2 = "SELECT * FROM dbtable2 WHERE dbtable2.id=$_GET[id];";
    $result2 = mysql_query($sql2);
    $result3 = mysql_fetch_assoc($result);
    $result4 = mysql_fetch_assoc($result2);
    ?>
    welcome to <?=$result3[username];?>'s profile.
    email: <?=$result4[email];?>
    [/code]

    just use $result3[dbtable] to get info from the first table in your database just change dbtable with your database fields, and the same for $result4[dbtable], just change dbtable to your field in your dbtable1.
  3. store all the emails in a file and separate each on by a |

    then do this

    [code]
    <?php
    $to1 = explode("|", "filename.txt");
    $to = $to1;
    $youremail = your@email.com;
    $subject= yoursubject;
    $msg = yourmessage;
    $headers='From: '.$youremail."\r\n".'MIME-Version: 1.0'."\r\n".'Content-type: text/html; charset=iso-8859-1'."\r\n";
    mail($to,$subject,$msg,$headers);
    ?>
    [/code]
  4. [code]
    <?php
    $connection = mysql_connect(localhost,dbuser,dbpass);
    $db = mysql_select_db(dbname,$connection);
        $sql = "SELECT * FROM user
                WHERE user.id='$_GET[id];'";
        $result = mysql_query($sql);
        $result2 = mysql_fetch_assoc($result);
        $user = $result2[username];

    ?>
    <?
    if($_GET[id] == false){
    echo "No user specify";
    }else {
    ?>
    <h3>Welcome to <?=$user?>'s profile.</h3><br>

    <? } ?>
    [/code]
  5. [code]
    <?php
    $get = $_GET[id];

    $sql = "SELECT * FROM dbtable WHERE user.id='$get';";
    $result=mysql_query($sql);
    $result2=mysql_fetch_assoc($result);
    ?>
    Welcome to <?=$result2[username]?> profile.
    [/code]

    For everything else $result2[DBFIELD];

    change dbfield to a field in your DB, whether it's username, email, website, or whatever
  6. or if you arent using mysql for this

    [code]
    <?php
    $pass = thepassyouwant;
    $user = theuseryouwant;
    $password = $_POST[password];
    $username= $_POST[username];

    if($password == $pass && $username == $user){
    echo "login right";
    setcookie("login","yes",time()+3600);
    }else{
    echo "wrong login";
    };
    ?>
    [/code]

    then for pages that require login

    [code]
    <?php
    if($_COOKIE[login] == yes){
    echo "stuff you want them to see";
    }else{
    echo "not logged in or bad auth";
    };
    ?>
    [/code]
  7. probably best if you used a working login script

    you can use mine if you want

    [code]
    <?php
      $connection = mysql_connect(host, dbuser, dbpass;
      $db = mysql_select_db(dbname, $connection);
      $sql = "SELECT * FROM dbtable
              WHERE username='$_POST[username]'
              AND password='$_POST[password]'";

      $result = mysql_query($sql);
      $num = mysql_num_rows($result);
      if ($num > 0) {                                // ### USER AND PASSWORD ARE CORRECT
        $id = mysql_fetch_assoc($result);

        setcookie("login", "yes", time()+3600);

      echo "login correct"


      }else{                                          // ### USER OR PASSWORD IS INCORRECT
        echo "wrong";
      }

    ?>
    [/code]

    then on pages if it requires authorization

    [code]
    <?php
    if($_COOKIE[login] == yes){
    echo "stuff they can see";
    }else {
    echo "bad auth";
    };
    ?>
    [/code]
×
×
  • 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.