Jump to content

IChaps

Members
  • Posts

    24
  • Joined

  • Last visited

Posts posted by IChaps

  1. Hello.

    I'd just like to enquire, what is the best way to encrypt and decrypt please?

    I've created a basic signup form, and I would like to encrypt the data before it's written to a database.

    Then when I come to create the log in screen, I would like to access the database, pull a record, then decrypt the email and password, to check it matches what the user has entered.

    Or is there an easier way?

     

    Thank You.

     

    ps. Also could I please just ask.  I've created a function for something else.  When I've finished with it, can I delete or destroy it?

    Thanks.

  2. Hello.

    I'd just like to ask about coping a picture file from one folder to another, then rename the copied file.  At present I've written:

    $mstr_dir = "/core/graphics/";
    $fle = "noimage.png";
    $usr_folder = "/core/user/images/";
    
    
    if (!copy("/core/graphics/noimages.png" , "/core/user/images/noimages.png")) {
        echo "ERR: ". error_reporting(E_ALL) . ini_set("display_errors", 1) . "<br>";
    }
    
    
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
    chmod("noimage.png",0777);
    $up_file = $last_id . ".png";
    
    
    rename ('/core/user/images/noimages.png' , '/core/user/images/' . $up_file);

     

    However I'm getting the error number 22519, and the file is not been copied.  I've already checked the path names and they do exist.

    Also with copy, I have tried " and ' both don't work.

    I'd just like to ask if theres an error in my code that I'm missing, and  any idea what the error number 22519 refers to?

    Thank You.

  3. Hello.

    I'd just like to enquire about loading a record/entry from a database and decryption.  Encryption is fine.

    To start with I'm rebuilding my login/sign in file (signin.php) to load a record from the registration database, then decrypt the record, to check the email and password fields.

    All I wanted to enquire is, should I place the decryption code in the signin.php file, or because I'll be accessing the registration database later on in my project as well. Should I place the decryption in a separate php file (say decryption.php for example)  and get the signin.php to load the decryption.php file?

    Any thoughts, or how would any one else go about it?

     

    Thank You.

     

  4. Hello Jomla.

     

    I'm a newbie teaching myself php and MySQL.

    I've been looking at session since I started in June 2016.

     

    The way I got to read a database MySQL was:-

     

    $db_host = "localhost"; // $db_host
    $db_user = "<database username>"; // $db_user
    $db_pass = "<database password>"; // $db_pass
    $db_databasename = "<database name>"; // $db_databasename

    $conn = new mysqli($db_host, $db_user, $db_pass, $db_databasename);

    if(! $conn)
    {
    die('Connection Failed'.mysql_error());
    }

    $sql = "SELECT Member_id, Fullname, Username, Email, Password, Location, Country, DOB, Gender, Relationship, Photo, Tzone, WebsiteURL, MembershipType, AccountStatus, BusinessAddress, SignupDate, LastVisitDate, is_online, AccountPrivacy, UserContactPrivacy, AutoRenewPass, AutoRenewDate, IP_Address, AccountClosedDate, AccountDeleteDate, Remarks FROM phpbear_registration";

    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
    if ( $row["Email"] == $user_email) {
    if ( $row["Password"] == $user_password) {
    switch ($row["AccountStatus"] ) {
    case "Suspended":
    echo "This account is Suspended.";
    header("Refresh:5; url=/index.php");
    $conn->close();
    exit();
    case "Closed":
    echo "This account was closed on:- ". $row["AccountClosedDate"];
    header("Refresh:5; url=/index.php");
    $conn->close();
    exit();
    }

    if ( $row["AccountStatus"] == "Active" or $row["AccountStatus"] == "New") {
    // echo "id: " . $row["Member_id"]. " - Name: " . $row["Fullname"]. " " . $row["Email"]. "<br>";
    // Get member's data from database
    $_SESSION['member_Member_id'] = $row["Member_id"];
    $_SESSION['member_Accountname'] = $row["Fullname"];
    $_SESSION['member_Username'] = $row["Username"];
    $_SESSION['member_Email'] = $row["Email"];
    $_SESSION['member_Password'] = $row["Password"];
    $_SESSION['member_Location'] = $row["Location"];
    $_SESSION['member_Country'] = $row["Country"];
    $_SESSION['member_DOB'] = $row["DOB"];
    $_SESSION['member_Gender'] = $row["Gender"];
    $_SESSION['member_Relationship'] = $row["Relationship"];
    $_SESSION['member_Photo'] = $row["Photo"];
    $_SESSION['member_Tzone'] = $row["Tzone"];
    $_SESSION['member_WebsiteURL'] = $row["WebsiteURL"];
    $_SESSION['member_MembershipType'] = $row["MembershipType"];
    $_SESSION['member_AccountStatus'] = $row["AccountStatus"];
    $_SESSION['member_BusinessAddress'] = $row["BusinessAddress"];
    $_SESSION['member_SignupDate'] = $row["SignupDate"];
    $_SESSION['member_LastVisitDate'] = $row["LastVisitDate"];
    $_SESSION['member_isonline'] = $row["is_online"];
    $_SESSION['member_Privacy'] = $row["AccountPrivacy"];
    $_SESSION['member_Contact_Privacy'] = $row["UserContactPrivacy"];
    $_SESSION['member_AutoRenewPassword'] = $row["AutoRenewPass"];
    $_SESSION['member_AutoRenewPasswordDate'] = $row["AutoRenewDate"];
    //$_SESSION['member_IPAddress'] = $row["IPAddress"];
    /* $_SESSION['member_AccountClosedDate'] = $row["AccountClosedDate"];
    $_SESSION['member_AccountDeleteDate'] = $row["AccountDeleteDate"];
    $_SESSION['member_Remarks'] = $row["Remarks"]; */
    /* $sql = "UPDATE phpbear_registration SET IPAddress='' WHERE Member_id='$userID'";
    mysqli_query($conn,$sql); */
    /* ------------------------------------------------------------
    if ($row["AccountStatus"] = "New") {
    $sql = "UPDATE phpbear_registration SET AccountStatus='Active' WHERE Member_id='$_SESSION['member_Member_id']'";
    $sql = "UPDATE phpbear_registration SET AccountDeleteDate='--/--/----' WHERE Member_id='$_SESSION['member_Member_id']'";
    mysqli_query($conn,$sql);
    }
    ---------------------------------------------------------------------------------------- */
    $conn->close();
    require($_SERVER['DOCUMENT_ROOT'].'/Core/user/user.php');
    exit();
    }
    }
    }
    }
    }
    $conn->close();

     

    I know it's a long winded but at that time I didn't know how else to store the results.

    Good Luck.

  5. Hello.

     

    I've created a small form with 6 text boxes and 2 select boxes/fields.

     

    The problem I'm facing is that I'm unable to post from the form to another php file.

     

    In the html form, I've written:-

    <form action="newmember.php" method="POST">
    <table>
    <tr>
    <td>Full Name / Business Name:</td>
    <td><input name="txtAccountName" size="20" maxlength="50"></td>
    <td></td>
    </tr>
    <tr>
    <td>Username:</td>
    <td><input name="txtUsername" size="20" maxlength="50"></td>
    <td></td>
    </tr>
    <tr>
    <td>EMail:</td>
    <td><input name="txtEmail" size="20" maxlength="100"></td>
    <td></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input name="txtPassword" type="password" size="20" maxlength="20"></td>
    <td></td>
    </tr>
    <tr>
    <td>Confirm Password:</td>
    <td><input name="txtConfirm_Password" type="password" size="20"></td>
    <td></td>
    </tr>
    <tr>
    <td>DOB:</td>
    <td><input name="txtdob" size="12" value="dd/mm/yyyy" maxlength="12"></td>
    <td></td>
    </tr>
    <tr>
    <td>Membership Type:</td>
    <td><select name="comMembership" size="1">
    <option selected="selected">Individual</option>
    <option>Business</option>
    </select>
    </td>
    <td></td>
    </tr>
    <tr><td></td></tr>
    <tr>
    <td>You Agree to our<br> Terms and Conditions,<br> and Privacy/Cookies Notice.</td>
    <td><select name="txtAgree" size="1">
    <option selected="selected">N</option>
    <option>Y</option>
    </select>
    </td>
    </tr>
    </table>
    <input name="submit" type="image" src="/mainimages/submit.jpg" style="border: 0" alt="">
    </form>

     

    And in the newmember.php file I've so far written:-

     

    <?php
    // Check Entries
    $New_Agree = $_POST["txtAgree"];
    $New_Fullname = $_POST["txtAccountName"];
    $New_Username = $_POST["txtUsername"];
    $New_EMail = $_POST["txtEmail"];
    $New_Password = $_POST["txtPassword"];
    $New_Confirm_Password = $_POST["txtConfirm_Password"];
    $New_Dob = $_POST["txtdob"];
    $New_Membership = $_POST["comMembership"];

    ?>

     

    I'd just like to ask:-

    1. Dose my coding look correct, as I've not been faced with posting problem before?

    2. Should I place the $_POST in html instead of php?

    3. Oh yes, I've found that the DOB is posted ok, however I've placed value="dd/mm/yyyy" as a temporary measure only.

     

    I'd be grateful for any ideas or guidance/help.

     

    Thank You very much.

  6. Hello.

     

    I'd just like to enquire about using session S_session please.

     

    I've created 4 sessions to hold the log in data for the access to a database (host, username, password, database name)

     

    At present I've got it to load this data from a file and insert it into a session.

    Then for my use I've got it to display this data, to ensure it's reading from the file - which it is doing correctly.

     

    The problem I've got is in another php file.

    In the other php file the sessions are all blank and I don't know why this is.

     

     

    ----

    In my index.php file the code reads [this works]:-

    //ReadFile
    $fp = fopen( dirname(__FILE__).'/Core/sys/dbinfo.txt', 'r' ) or die("Couldn't open file:- 1");
    $db_host = fgets($fp);
    $db_user = fgets($fp);
    $db_pass = fgets($fp);
    $db_databasename = fgets($fp);
    fclose( $fp );

    $_SESSION['dbf_host'] = $db_host;
    $_SESSION['dbf_user'] = $db_user;
    $_SESSION['dbf_pass'] = $db_pass;
    $_SESSION['dbf_databasename'] = $db_databasename;

     

    and in the other php file, the code reads:-

    session_start();

    echo "new php file\n";

    echo $_SESSION['dbf_host'];
    echo $_SESSION['dbf_user'];
    echo $_SESSION['dbf_pass'];
    echo $_SESSION['dbf_databasename'];

     

    The above code produces a blank screen.

     

    Could anyone please advise me?

    Thank You.

  7. Hi,

     

    Could I please briefly enquire about reading and writing to a file using php?

     

    I'm looking for a way of storing a database's, Name, Username and Password. Then reading it back again.

     

    Writing to a file, I've written:-

     

    // Write to file.
    $fp = fopen( dirname(__FILE__).'/sys/dbinfo.txt', 'w' ) or die("Couldn't open file:- ");
    fwrite($fp, $hostname);
    fwrite($fp, $database);
    fwrite($fp, $username);
    fwrite($fp, $password);
    fclose( $fp );

     

    and to read back, I've written:-

     

    $fp = fopen( dirname(__FILE__).'/sys/dbinfo.txt', 'r' ) or die("Couldn't open file:- ");
    $db_host = fread($fp, $hostname); // $db_host
    $db_user = fread($fp, $username); // $db_user
    $db_pass = fread($fp, $password); // $db_pass
    $db_databasename = fread($fp, $database);
    fclose( $fp );

     

    However, I'm finding the data is been written in one long string (ie localhostusernamepassworddatabasename).

     

    I'd just like to ask if it is possible read the file so that $db_host would hold just hostname, $db_user would hold just the database username and so on?

     

    Also (out of interest) is there another way of reading and writing. I've thought about keeping each piece of data in a separate file.

     

    Thank You.

     

  8. Hello.

     

    I'd like to request a little guidance with regards forms and updating a database table please.

     

    I've created a form which has a dropdown list.

     

    I'd just like to enquire:-

     

    1. How do I pass the selected result from the dropdown list to a variable? (at present I've written:- $user_gender = $_POST["profile_gender"] ;)

     

    2. I'm unable to update the database table. The database opens and there's no errors reported. I'd just like to ask the following looks ok? $sql = "UPDATE registration_table SET Gender='$user_gender' WHERE Member_id='$userID'";

     

    Thank You.

     

  9. Hello.

     

    I'd just like to enquire how I would read and write to a file using php please?

    I'm looking to write a database's, Host, Username, Password, and database Name to a file name on the server, then at a later date. When I load the site, read this information back.

     

     

    At present I'm using the following to write to the file:-

    // Write to file.
    $fp = fopen( dirname(__FILE__).'/dbinfo.txt', 'w' ) or die("Couldn't open file:- ");
    fwrite($fp, $hostname);
    fwrite($fp, $database);
    fwrite($fp, $username);
    fwrite($fp, $password);
    fclose( $fp );

     

    and to read back:-

     

    $fp = fopen( dirname(__FILE__).'/dbinfo.txt', 'r' ) or die("Couldn't open file:- ");
    $db_host = fread($fp, $hostname); // $db_host
    $db_user = fread($fp, $username); // $db_user
    $db_pass = fread($fp, $password); // $db_pass
    $db_databasename = fread($fp, $database);
    fclose( $fp );

     

    However, it reads it all in one long string, instead of it been on separate lines.

     

    Would anyone know the correct way of writing this code, please?

     

    Thank You.

  10. Hello.

     

    Could anyone familiar with mysqli advise me with regards reading and searching a database please?

     

    After connecting to the database, and opening it.

     

    So far, I've written the following:-

     

     

    $sql = "SELECT Member_id, Fullname, Username, Email, Password, Location, Country, DOB, Gender, Photo, Tzone, WebsiteURL, MembershipType, AccountStatus, ShortURL, BusinessAddress, SignupDate, LastVisitDate, AccountClosedDate, AccountDeleteDate FROM registration";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
    // output data of each row
    while ($row = $result->fetch_row()) {
    if ( $row[3] == $user_email & $row[4] == $user_password) {

    echo "Found Entry";

    }

    }

    }

    mysqli_close($conn);

     

    I'm finding that the above, will only read the first record/entry in the database, and will not read/search the rest of the database.

     

    I'd like to ask/request how do I go about searching the rest of the database? As I don't know how to proceed with it.

     

    Thank You.

     

  11. Hello again.

     

    I've tried the suggestion above, however I can't get it to work, as I'm getting a blank field.

    I have also written the code below, and I'm still getting a blank field next to the Account Name.

     

    Could I please request if anyone could write the correct coding for me?

    Thank You.

     

     

     

    <div id="editform">
    <form name="edit_account" action="EDITING" method="POST">
    <table style="border-size: 0px">
    <tr>
    <td width="25%">Account Name:</td>
    <td width="11%"></td>
    <td> <input name="profile_fullname" value= "<?php echo $_SESSION['$member_Fullname']; ?>" maxlength="20"></td>
    </tr>
    <tr>
    <td width="25%">Username:</td>
    <td width="11%"></td>
    <td><input name="profile_username" value=$username maxlength="20"></td>
    </tr>
    <tr>
    <td width="25%">EMail:</td>
    <td width="11%"></td>
    <td><input name="profile_email" type="text" value="mememail"></td>
    </tr>
    <tr>
    <td width="25%">Password:</td>
    <td width="11%"></td>
    <td>*****</td>
    </tr>
    <tr>
    <td width="25%">Location:</td>
    <td width="11%"></td>
    <td><input name="profile_location" type="text" value="location" maxlength="20"></td>
    </tr>
    <tr>
    <td width="25%">Country:</td>
    <td width="11%"></td>
    <td><select name="country" size="1">
    <option selected="selected">United Kingdom</option>
    </select> ></td>
    </tr>
    <tr>
    <td width="25%">DOB:</td>
    <td width="11%"></td>
    <td> <?php $_SESSION['$member_DOB']; ?> </td>
    </tr>
    <tr>
    <td width="25%">Gendar:</td>
    <td width="11%"></td>
    <td><select name="gender" size="1">
    <option>Male</option>
    <option>Female</option>
    </select></td>
    </tr>
    <!-- <tr>
    <td width="25%">Profile Photo:</td> memphoto
    <td width="11%"></td>
    <td>Form Basic 9</td>
    </tr> -->
    <tr>
    <td width="25%">Time Zone:</td>
    <td width="11%"></td>
    <td><select name="timezone" size="1">
    <option>GMT</option>
    </select></td>
    </tr>
    <tr>
    <td width="25%">Website URL:</td>
    <td width="11%"></td>
    <td><textarea name="profile_websiteurl" value="website"> </textarea> </td>
    </tr>
    <!-- <tr>
    <td width="25%">Membership Type:</td> memtype
    <td width="11%"></td>
    <td> <?php $_SESSION['$member_MembershipType']; ?></td>
    </tr>
    <tr>
    <td width="25%">Account Status:</td> memstatus
    <td width="11%"></td>
    <td><?php $_SESSION['$member_AccountStatus']; ?></td>
    </tr> -->
    <tr>
    <td width="25%">Short URL:</td>
    <td width="11%"></td>
    <td><input name="profile_shorturl" value="$shorturl"></td>
    </tr>
    <tr>
    <td width="25%">Business Address:</td>
    <td width="11%"></td>
    <td> <textarea name="profile_businessaddress"> </textarea> </td>
    </tr>
    <tr>
    <td width="25%">Date Joined:</td>
    <td width="11%"></td>
    <td> <?php $_SESSION['$member_SignupDate']; ?> </td>
    </tr>
    <tr>
    <td width="25%">Last Visited:</td>
    <td width="11%"></td>
    <td><?php $_SESSION['$member_LastVisitDate']; ?></td>
    </tr>
    </table>
    </form>
    </div>

  12. Hello Ingolme,

     

    Thank you for you reply.

    It's been about 8-10 years since I built a web site, so things may have changed some-what.

     

    The line I specified above, was used when I used FrontPage 2000/2002.

     

    Now, all attempts to use include in html has failed.

    I've used the guide on w3schools's site and I can't get to this to work for some reason.

     

    I just don't know what else to try.

    I'd welcome any help.

     

    Thank You.

  13. Hello.

     

    I'd just like to enquire, how would I include one html file in another?

     

    I'm using a bootstrap theme. I've created a menu, which I would like to include on a few more pages I'll be creating.

     

    I have used the old method - <!-- webbot bot="Include" U-Include="mainmenu.html" TAG="BODY" --> but I can't get this to work.

     

    I've also used iframe but all I get is a blank square.

     

    Could anyone please help?

     

    Thank You.

     

     

  14. Hello..

     

    I'd like to enquire if I can show 2 php files side by side?

     

    for example:-

     

    in a index.php, can I

     

    include a menu.php on the left-hand side, and another php file next to it?

     

    I'm not sure how to do this, however I've tried to achieve it in html, and failed.

     

    Can anyone help please?

    Thank You.

  15. Hello.

     

    I'm just starting out with css, and I would like to enquire about setting widths, and inserting php.

     

    I've created a 3 column page in css/html using my css editor's template.

     

    I would like to insert a menu on the left hand side, which I've created in php, and set the width.

    However I can't figure out how to do this.

     

    Also, using iframe, there is a box created with stretches over 2 columns, I would like to ask how do I set the width of this.

     

    I've attached a screen print of my template

     

    Thank You.

     

  16. Hello.

     

    I'm looking to build a menu for my project.

     

    I'm just enquiring:-

    1. Once I've retrieved the entry from the database, How do I create an array?

    2. Once the array is created, how do I show a small picture, basic text (ie Home Page), and a hyperlink please?

     

    Thank You.

     

  17. Hello Justsomeguy.

     

    Thank you for your reply and help.

    I've re-build the file line by line, and found the error. (it took me a while).

    There was a line missing, and it was not writing back to the database, as well as the error in the line you mentioned.

     

    Kind Regards.

  18. Hello.

     

    Thank you justsomeguy for your reply.

     

    I've attached a specimen of mySQLi / php code (minus the database and login details).

    It appears to read from the database, display the queried email and old password.

    Then generate a new pass number and display this.

     

    But I can't get it to write back to / update the database.

    I have thought about deleting the entry and re-inserting it.

     

    I don't know enough about PDO at present.

     

    As I unable to figure out how to do this, Could I request that the required update line be written for me please?

     

    Thank You.

     

  19. Hi,

     

    I'm currently experiencing difficulties updating the database.

    I'm currently creating a 'Forgotten Password' feature.

     

    I've finished most of it, however when I attempt to update the database with a new password, nothing happens and the old password remains in the database.

     

    I've followed W3Schools example but I'm stuck.

     

    ---------

    The new password is generated by numbers 4 in total, ie $new_pass = (rand(1000,9999);

    and from the form I've used $user_email= $_POST["retrieve_email"];

     

    then I use the line

    sql = "UPDATE registration SET Password=$new_pass WHERE Email=$user_email";

     

    I can't get it to work, and I don't know why.

     

    Could anyone please write the code I need to make it work, or let me know how to proceed?

     

    Thank You.

     

    ps. I thought about deleting the entry and re-inserting it. Would that work (out of interest)?

     

     

  20. Hello,

     

    Can I please ask, how do I go about updating a entry in a database?

    I'm trying to create a Forgotten Password feature.

     

    I can open a database, and locate the required entry.

    But each time I try and replace the old password with a new one. The database is not been updated.

     

    My update reads:-

    $sql = ("UPDATE registration SET Password='$old_pass', WHERE $row[0]='$userID'");

     

     

    May I ask how should I proceed?

     

    Thank You.

     

    • Like 1
  21. Hello.

     

    Apologies, if I've posted in the wrong forum.

     

    What I would like to ask is.

     

    I'm creating a simple login screen, and once the user's username and password is matched with what's held on the database.

    I would like to store the user's fullname, email and membershiptype in a session so I can call it up in another php file later on.

     

    At present, I'm able to connect and open the database, then read from it. Then I'm getting stuck.

     

    I'm getting errors on lines:-

    $member_members_id = $_REQUEST['member_id'];

    $member_fullname = $_REQUEST['fullname'];

     

    Could any one please help?

     

    Thank You.

     

     

     

×
×
  • Create New...