/    Sign up×
Community /Pin to ProfileBookmark

Not even sure what I need to learn!

I have been writing webpages for a while now but I need a new one to do something that I don’t know how to do, and don’t even know what the function is called! It’s hard to research the answer without the question!

Here’s what I want it to do, actually there are 2 different things I need….
1) We have a restaurant website. I want to be able to have an admin page where we can enter the daily specials and have them appear in a cell on a table on one of my pages. I’m flexible on where it appears, if it has to be it’s own page, that’s okay, it can be made into a popup.

Would this be a database? Can I do this with Access?

2) I want people to be able to assemble an order from a form, but we have a HUGE menu. If I were to put all of the items with all of the possible combinations of questions (fries, soup or salad? what kind of dressing would you like on your salad? etc.) it would be enormous and no one would want to use it. Ideally, all of our items would be listed and if they checked one, say a burger, then a unique set of questions would pop up for that specific item (temperature, add ons, sides, special instructions). Then the next item can be ordered. all of this info would be assembled into an email or even a text document that they could print and fax to us.

So, what is that? asp? php? am I on pcp just for thinking this is possible? ?

Thanks for your time!
T-

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Sep 05.2010 — #1 is very easy. Any server-side language will do it for you, I'd suggest PHP. Any tutorial will enable you to do that.

#2 is a little more tricky to implement, but not that difficult. For it to be totally accessible (i.e. work without JavaScript), the front-end requires a combination of PHP and JavaScript, or it can be implemented entirely in JavaScript. You then need to write a simple script in PHP to process that order (you could get it emailed to you if you wished).

So in short, learn PHP. You'll then be able to implement #1 easily as well as a barebones #2, and with a little JavaScript (AJAX to be precise), you can get an accessible, efficient #2. If you ask for help with specific problems along the way, we can be of more help.
Copy linkTweet thisAlerts:
@iRedMediaSep 05.2010 — He's right ^.

I'm gonna get a little specific here, and give you a crash course on creating a login module. (Very simplified)

[FONT="Arial Black"][SIZE="4"]Intro of PHP & Javscript[/SIZE][/FONT]

PHP is a server side web programming language. That basically means that the code which is written, is compiled by the server, BEFORE it is sent to the client (the user who'll be viewing the page), as simple HTML. In short, PHP is used to verify passwords, execute if/else statements, and OUTPUT HTML. (It's bold because it's important). The browser is sent directly to these PHP pages, input/output is required, and calculations are made. (eg yourdomain.com/login-form.php)

Javascript is a client side langauge (for the most part). This means that the browser will do all the compiling & executing of the code. This language much like php, can do if/else statements, output/modify html, and has a LOT of libraries, which are compilations of pre-setup code which is secure, fast, and created for todays modern adaptations of the web. Google - Javscript libraries. jQuery is common one, and AJAX can help as well.

[FONT="Arial Black"][SIZE="4"]The Login[/SIZE][/FONT]

The login-form contains three small entities, a username input, password input, and of course, the login button. I'm going to assume you're very familiar with HTML, and know how to create forms, and such. If not Google it ?.
[code=html]<form id="loginForm" name="loginForm" method="post" action="login-exec.php">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="112"><b>Login</b></td>
<td width="188"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</form>[/code]


[FONT="Arial Black"][SIZE="4"]The Login Process[/SIZE][/FONT]

This form contains the items we spoke about, and you'll notice the attribute "action" in the "form" tag. This tells the browser where to send the information acquired from the login page. This "action" page will process the login information by:
[LIST=1]
  • [*]Opening database connection

  • [*]Retrieve login information

  • [*]Create query to check for valid login

  • [*]Login if values are correct, redirect to login page otherwise

  • [/LIST]


    [CODE]<?php
    //Start session
    session_start();

    //Include database connection details,
    require_once('config.php');
    require_once('connect.php');

    //Function to sanitize values received from the form. Prevents SQL injection
    function clean($str) {
    $str = @trim($str);
    if(get_magic_quotes_gpc()) {
    $str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
    }

    //Sanitize the POST values
    $login = clean($_POST['login']);
    $password = clean($_POST['password']);

    //Input Validations
    if($login == '') {
    $errmsg_arr[] = 'Login ID missing';
    $errflag = true;
    }
    if($password == '') {
    $errmsg_arr[] = 'Password missing';
    $errflag = true;
    }

    //If there are input validations, redirect back to the login form
    if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: login-form.php");
    exit();
    }

    //Create query, using MYSQL
    $qry = "SELECT * FROM members WHERE login='$login' AND password='".md5($_POST['password'])."'";
    $result = mysql_query($qry);

    //Check whether the query was successful or not
    if($result) {
    if(mysql_num_rows($result) == 1) {
    //Login Successful
    session_regenerate_id();
    $member = mysql_fetch_assoc($result);
    $_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
    $_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
    $_SESSION['SESS_LAST_NAME'] = $member['lastname'];
    session_write_close();
    header("location: cms/index.php");
    exit();
    }else {
    //Login failed
    header("location: login-failed.php");
    exit();
    }
    }else {
    die("Query failed");
    }
    ?>[/CODE]


    This is a good start to your problem. I found when I was looking for help in web languages, a lot of the solutions were either too advanced, or gave you the entire solution in one big chunk. This is exactly what I'm not doing here. I left out a great amount of detail, including how you connect to the db. The reason is, it helps you learn faster. If you read countless "beginners guides to php" you'd get a lot of lame color changing squares, repeating number sequences, and such. Don't get me wrong.. the essentials, are essential. You, however, need a specific implementation. I hope my pieces will help you.

    What you really need to do, is read through it, try and figure it out (commenting helps a lot eh?). Whatever you can't, feel free to post back here. You need to figure out how to create & connect to a MySQL database, how to login using PHP, and then, how to write & retrieve data to your server, to create a CMS of sorts. I'll probably end up writing a tutorial on how to do this in the next few days anyways. Keep me posted on your success!
    ×

    Success!

    Help @tooie6 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...