Jump to content

Web development


baragan
 Share

Recommended Posts

hey every 1. i am new to webdesign i am trying to make my first dynamic site and i am having a hard time on where to start or lets say just the whole procedure in general.though i know every1 has his own way of doing things but can any1 please give me an insight of how they break down their projects from the first code to a working website because i am wasting alot of time thinking on where to start. thanks.

Link to comment
Share on other sites

I guess you start at the beginning. Normally you should create your design plan first, where you write out all of the features you want your project to have. When I start writing code, like a new project I'm building from scratch, the first files I create are typically the include files that I'll need on every page that have settings and things defined in them. Things like the database connection information, site metadata, whatever global settings or options that I'll be using on every page. I'll have only one global include file, if I need more than that one file included on every page then those additional include statements will go in the global include file. Here's an example of one file like that:

<?php # check requirementsif (version_compare('5', PHP_VERSION, '>')){  echo 'Error: The application requires PHP version 5 or later.';  exit();} if (!class_exists('ZipArchive')){  echo 'Error: The application requires the PHP Zip extension to be loaded in order to extract uploaded content packages.  See this link for more information: <a href="http://www.php.net/manual/en/zip.installation.php">http://www.php.net/manual/en/zip.installation.php</a>.';  exit();}if (!function_exists('simplexml_load_file')){  echo 'Error: The application requires the PHP SimpleXML extension to be loaded in order to process uploaded content packages.  See this link for more information: <a href="http://www.php.net/manual/en/book.simplexml.php">http://www.php.net/manual/en/book.simplexml.php</a>.';  exit();} error_reporting(E_ALL);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('log_errors', 1);ini_set('display_errors', 0);ini_set('memory_limit', 67108864);$php_command_line = strpos(php_sapi_name(), 'apache') === false && (strpos(php_sapi_name(), 'cgi') !== false || strpos(php_sapi_name(), 'cli') !== false); require_once 'global.config.php';// check for SSL and update http_root if necessaryif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'){  $config['http_root'] = str_replace('http://', 'https://', $config['http_root']);} date_default_timezone_set($config['timezone']);if (!$php_command_line){  $cookie_info = session_get_cookie_params();  session_set_cookie_params($cookie_info['lifetime'], '/', $config['cookie_domain'], $cookie_info['secure'], $cookie_info['httponly']);}require_once 'functions.global.php'; require_once 'class.db.php';$db = new tc_lms_database($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']);require_once 'class.lang.php';$lang = new tc_lms_lang(); if (!$php_command_line){  require_once 'class.session.php';  $sess = new tc_lms_session();}require_once 'class.userfield.php';require_once 'class.userfields.php';$uf = new tc_lms_userfields(); require_once 'class.config.php';$opts = new tc_lms_config();require_once 'class.datacache.php';$cache = new tc_lms_datacache($config['cache_timeout']); require_once 'functions.usergroups.php';require_once 'functions.images.php';require_once 'functions.content.php';require_once 'functions.emails.php';require_once 'functions.dates.php';require_once 'functions.change.logs.php'; if (!empty($_GET['theme'])){  $config['ext_theme'] = $_GET['theme'];  $sess->set_val('ext_theme', $config['ext_theme']);}if (!empty($_GET['cid']) && count($_GET) == 1) // only redirect to content if it's the only parameter, otherwise it's used for reports and other things{  $sess->set_val('auto_launch_cid', $_GET['cid']);  $sess->redirect($config['http_root']);} if (!empty($_GET['creg'])){  $sess->set_val('auto_register_class', $_GET['creg']);  $sess->redirect($config['http_root']);}if (!empty($_GET['wreg'])){  $sess->set_val('auto_register_web', $_GET['wreg']);  $sess->redirect($config['http_root']);} ?>

That code first checks various requirements, then it sets various PHP settings and options, then it includes a config file that defines an array called $config which contains various options and settings for the application. Then it goes through and does various checks, includes other files and creates objects, etc, things that I need to happen on every request to the application. This file gets included on every page in the application, the other pages will not work without including this file because they rely on everything else it does. Once you have your basic architecture set up like this, then you can start writing the application code. Where you start there is up to you, but it's usually best to take it one feature at a time. Start with a login system or something if your application needs one, or if you're just building a regular site then start with your home page. You'll probably end up rewriting a lot of code once you figure out a better way to do things.

Link to comment
Share on other sites

I usually work on the interface portions and the server-side portions separately, so I'll work on any HTML, CSS, and Javascript with or without a working PHP backend. Once you have each piece working individually it's trivial to combine them into the final product.

  • Like 1
Link to comment
Share on other sites

hello everyone!I am new on this forum, I guess chose right topic for my question.it is about php and mysql databaseI have database with table 'pisoar' with columns 'id', 'autor', 'biser' (it is on my mother tongue, if it is weird to you :D ) here is a code, so, can anyone detect error please. It is in <html><body><div> tag after connecting and selecting database <textarea rows="10" cols="10" name="biser"></textarea><?php$biser = $_POST['biser'];$data = mysql_real_escape_string[$biser]; // my output is that there is unexpected '[' here, but I don't think somysql_query("INSERT INTO pisoar (id, autor, biser) VALUES ('', 'mama', '$biser');") or die (mysql_error()); // id is auto_increment?> So, here is what I want to do.when user write something in textarea, it will be data for sending to a database Thanks

Link to comment
Share on other sites

Hi Lazyman, Be best if you posted your question(s) in the PHP forum, but at this line: $data = mysql_real_escape_string[$biser]; .. try changing it to this: $data = mysql_real_escape_string($biser);

  • Like 1
Link to comment
Share on other sites

thank you, it works, no errors. But there is no button for sending data to database, just textarea. If I put it to form , when user press submit button, data is not sending to database, but it is opening new tab with text like 'not found' or similar. Can anyone help me with this, I would be grateful, if it means anything to you :D

Link to comment
Share on other sites

all right, here is it <?$con = mysql_connect("you will","not get","my password"); // :Dmysql_select_db("database", $con);$podaci = mysql_query("SELECT * FROM pisoar WHERE autor='mama'") or die(mysql_error());while ($mama = mysql_fetch_array( $podaci )) { ?><ul><li><? echo $osoba['biser']; ?></li></ul> <?}?><textarea rows="10" cols="10" name="biser"></textarea><?$biser = $_POST['biser'];$data = mysql_real_escape_string($biser);mysql_query("INSERT INTO pisoar (id, autor, biser) VALUES ('', 'mama', '$biser');") or die (mysql_error());mysql_query("DELETE FROM pisoar WHERE biser=''") or die (mysql_error()); // this is because every time when webpage reload, empty data sneds to my database?> I have database with table 'pisoar' with columns 'id', 'autor', 'biser' (it is on my mother tongue, if it is weird to you :D )So, this is not a big problem, every1 of you is more xp in this, because, I am just a teenager, but unlike my teens, I don't play computer games or wasting time on fb, but learning this, this is my first webpage, I relly want to learn

Edited by lazy-man
Link to comment
Share on other sites

You're not checking if the form was submitted before you try to insert data. That's why it keeps adding blank rows. You should check if the form was submitted, if there is any information in $_POST, before trying to process it. If pressing the submit button opens the form in a new tab to a page it can't find then that's a problem with the action and target attributes on your form tag. The action should be set to the same page, the one that processes the form, and you don't need a target on the form. This thread shows one way of checking if a form was submitted: http://w3schools.invisionzone.com/index.php?showtopic=12509

Link to comment
Share on other sites

thanks for the tip justsomeguy. i'll try out your way and tell you how i fared. i took almost 3 to 5 days in my previous project just trying to come up with a template that looked appealing. When you started creating websites (if you remember lol) did you have a feeling that it wasn't good enough coz i think thats what contributes to me wasting alot of time.

Link to comment
Share on other sites

When you started creating websites (if you remember lol) did you have a feeling that it wasn't good enough coz i think thats what contributes to me wasting alot of time.
It's still never good enough. You'll always a find a better way to do what you were doing before, even if the first or second or third time you did it you thought it was the greatest thing that ever happened to mankind. That applies to a lot more than just making websites.
Link to comment
Share on other sites

When you started creating websites (if you remember lol) did you have a feeling that it wasn't good enough coz i think thats what contributes to me wasting alot of time.
i dont think it is wasting of a time. if you find ways to get better your codes later, it means you are improving and your thinking is improving. good codes comes with experiance and experiance comes with mistakes a lot of mistakes. just write code from what skill level you are in and when you feel it could be better, chage it.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...