Jump to content

Can PHP do this?


Visvalor

Recommended Posts

Ok what I want to do is make a form style site reminiscent of those old address books you'd find in BASIC business software back in the 80s

Attatched is a picture file with the general idea of what I want to do. I want a form button that will create (on the page) a table form that can hold variables to be saved to the user account (like an address book let's say) and recalled when the user logs in. 

I'd also like it to have a self deleting button on each table for easy maintenance. 

Can PHP even do this and where would I start if so?

 

Thanks for any help!

post-86204-0-69549300-1432339417_thumb.jpg

Link to comment
Share on other sites

I'm not sure how much knowledge you have of php or coding in general, here is the php manual and tutorial.

 

This could all be done. Using html forms with POST or GET requests. There is various ways to handle the storage such as a database, session, or even flat files. The editing or deletion process can be done using forms or requests, more dynamic methods without refreshing the current page done with javascript/ajax or jquery.

 

I'll try to explain and link to some specific areas of interest.

For the database use either pdo or mysqli functions for handling the connections,insert,update or fetch.

 

user accounts with login

password_hash() and password_verify() should be the 2 functions using to add users passwords and verify is them

You would save the username,hashed password and any other information into a database upon registration.

For login you would query the database that user and using password_verify to ensure the password is correct.

Once you verify the user/password you create a session

$_SESSION['username'] = $user;

You can save a specific session key and value for that user, some use a numbering system for admin or user privileges and additionally their username

session_start(); must be at the top of every script for this to work

$_SESSION is an array of the session keys and values

 

$_POST or $_GET methods from the html form are arrays, so you would check if one of your desired array keys is set and not empty to determine what to do.

isset() checks if a variable is set

trim() would remove any whitespace from the ends

 

some examples

session_start();

if(isset($_SESSION['username']) && trim($_SESSION['username']) !=''){
    $username = trim($_SESSION['username']);
    $logged_in = true;
}else{
    $username = '';
    $logged_in = false;
}

if(isset($_POST['key']) && trim($_POST['key']) !=''){
    $value = trim($_POST['key']);
}else{
    $value = '';
}

You should always use filters and escape the input to ensure is data you expect, clean and safe.

ctype character type checking

validate filter

sanitize filter

 

If using pdo use prepared statements, if using mysqli functions use mysqli_real_escape_string()

 

For redirecting a user a different location such as they don't have high enough privileges use header()

 

Take one step at a time and any specific questions you have during creation post again and include the related code you have.

What you want is basically your own cms and not some simple code.

Link to comment
Share on other sites

For my two cents, yes is most *definitely* can be done with PHP, in fact this project is bowling straight onto PHP's bat.

 

As quickoldcar has mentioned, you'll need to partner it up with a database eg MySQL or even a flat file. But again, this is absolutely no problem at all for PHP

 

Just a word of caution though ... this is not an insignificant project, and it will take rather a bit of time to put together especially if you are a newbie, so you need to carefully manage your expectations. However, this could be a *perfect* project to use to learn PHP!  I learned all my PHP from doing small practical projects, slowly building up as I went along.

 

Quickoldcar has given you some great tips and links to get you going. You would also find it beneficial to have at least a basic working knowledge of HTML and some javascript and CSS would not go amiss either if you want it to look really snazzy.

 

GOOD LUCK !!

Link to comment
Share on other sites

Thanks for the help! Yes this is my first PHP project. I've got HTML pretty much down and a strong understanding of CSS. I'm looking into Javascript now (as is the order so far in the w3schools page) before heading into PHP. The concepts aren't unfamiliar I took a Python class in college for giggles and had to learn a lot of LUA for another project. I'm just making sure PHP can do this and I'm not on the wrong track.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.