veedeoo 474 Junior Poster Featured Poster

Before giving response to your inquiries, please allow me to point out problem on your codes that needs to be fix immediately.

Please read one and two.

We must not use $_REQUEST when processing form data from user. The reason is that $_REQUEST is like a garbage disposal it will process "post" and "get" $_SERVER['REQUEST_METHOD']. We want to be more specific on which one to use. e.g. post or get.

Most hackers are focusing on PHP's superglobal variables vulnerabilities. To make the matter worse, your script is using $_REQUEST.

Although the link I have provided above is somewhat focused on the session exploits.

I wish I could explain this topic in great detail, but due to time constraint, I wrote a simple function for you to experiment and observe the behavior of the form processor with $_REQUEST.

In my humble opinion $_REQUEST is a lazy tool for a lazy developer. A developer who is lazy to define the appropriate method for the from processor.

Let's prove that your code will fail. Create a new file formtest.php

<?php 

    function adaptive_form($method)
    {

        $form ='<form method="'. $method .'" action="">
                <input type="text" name="name"/>
                <br/>
                <input type="password" name="pass"/>
                <br/>
                <input type="submit" name="submit" value="submit"/>
                </form>';

                return $form;

    }


    if(isset($_REQUEST['submit'])){
            echo $_REQUEST['name'];
            echo '<br/>';
            echo $_REQUEST['pass'];
    }

    ## call the function above with different params
    echo '<br/>';    
    //echo adaptive_form('');
    //echo adaptive_form('get');
      echo adaptive_form('post');

Uncomment one at a time and test by directing your browser to formtest.php

    //echo adaptive_form('');
    //echo …
veedeoo 474 Junior Poster Featured Poster

I'm sorry Enersto, I already tried really really hard. For some reason, I can't see it on my crystal ball. :)

1e4033c4e499e21349572cdd326c846e

image was lifted from here without permission.

veedeoo 474 Junior Poster Featured Poster

this will grab date from remote server file as long as public viewing is allowed. :)

<?php 


$client_file_loc = 'someRemoteLocation/file.txt';

echo (get_timestamp($client_file_loc));


function get_timestamp($url)
{

    $this_curl = curl_init($url);

    ## reference read from => http://curl.haxx.se/libcurl/c/CURLOPT_NOBODY.html
    curl_setopt($this_curl, CURLOPT_NOBODY, true);
    curl_setopt($this_curl, CURLOPT_RETURNTRANSFER, true);

    ## the magic will be taking place here and as reference => http://curl.haxx.se/libcurl/c/CURLOPT_FILETIME.html
    curl_setopt($this_curl, CURLOPT_FILETIME, true);

    $this_res = curl_exec($this_curl);

    if($this_res === false){

            die (curl_error($this_curl)); 

    }

    ## reference read from curlHaxx => http://curl.haxx.se/mail/lib-2005-12/0181.html
    $file_creation_time = curl_getinfo($this_curl, CURLINFO_FILETIME);

    if ($file_creation_time != -1) {

    return date("Y-m-d H:i:s", $file_creation_time);

    } 

    else{

            return false;
    }

}

this may not work on .asp, .php, .inc, .cgi file extensions. I have other means of doing it with those file extensions, but I think that is out of ethics to invade or rather intrude someone elses files.

veedeoo 474 Junior Poster Featured Poster

You can use cURL for this, except after cURL execution you must add

$file_creation_time = curl_getinfo($curl, CURLINFO_FILETIME);

## use the file_creation_time for whatever you want

echo date("Y-m-d H:i:s", $file_creation_time);

another alternative is the PHP get_headers() function which can easily return the date. e.g.

$client_file_loc = 'some_remote_url';
$this_x = get_headers($client_file_loc, 1);

## this_x returns an array including the date which [1]

echo $this_x[1];
veedeoo 474 Junior Poster Featured Poster

you need to add position like so

 $result_dglass = mysql_query("select name, id, position from team where position like '%gk%' order by id Asc");
veedeoo 474 Junior Poster Featured Poster

how do you populate the dropdown?

    <option><?php echo $row['name'];?></option>

Otherwise, you want to add it on your query e.g. id,

    $result_dglass = mysql_query("select name, id from team where position like '%gk%' order by id Asc");

then you can have at least another item on your option

<option value="<?php echo $row['id'];?>" ><?php echo $row['name'];?></option>
veedeoo 474 Junior Poster Featured Poster

here is another really quick and dirty MySQLI connector using foreach loop .

<?php

$con =mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

## Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

    $sql='SELECT * FROM search WHERE function LIKE "%'.$search_string.'%" OR name LIKE "%'.$search_string.'%"';

    $result=mysqli_query($con,$sql);

    ## Fetch all all the result array
    $result_array = mysqli_fetch_all($result,MYSQLI_ASSOC);

    ## Free result_array set
    mysqli_free_result($result_array);

    mysqli_close($con);

    foreach($result_array as $v){

        echo $v['function'].'<br/>';
    }
veedeoo 474 Junior Poster Featured Poster

I really don't to be reiterating the common knoweledge at all times, but I think this one is one of those exemptions.

Codes below are bad

// Connection
global $tutorial_db;
$tutorial_db = new mysqli();
$tutorial_db->connect($dbhost, $dbuser, $dbpass, $dbname);
$tutorial_db->set_charset("utf8");
// Check Connection
if ($tutorial_db->connect_errno) {
printf("Connect failed: %s\n", $tutorial_db->connect_error);
exit();
}

We can instantiate the MySQLI object in one declaration like this

$tutorial_db = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

we catch error if there is one

    if ($tutorial_db->connect_errno) {
        printf("Connect failed: %s\n", $tutorial_db->connect_error());
        exit();
      }

I still don't understand the unecessary while loop followed by foreach loop. However if that is what you want, change this block of codes

 // Do Search
    $result = $tutorial_db->query($query);
    while($results = $result->fetch_array()) {
    $result_array[] = $results;
    }

with this

 $result_array[] = array(); //or like this $result_array = array();
 $result = $tutorial_db->query($query);
    while($results = $result->fetch_assoc()) {
    $result_array[] = $results;
    }

Alternatively, you can eliminate the entire foreach loop and just do it like this

$result = $tutorial_db->query($query);

if($result->num_rows > 0) {
    while($result_array = $result->fetch_assoc()) {

    /*
    * add items from foreach loop here as shown on your code
    */

    echo $result_array['function']; //this is a test

    }
}

else {

echo 'Sorry your request does not exist';

}
veedeoo 474 Junior Poster Featured Poster

I want to add
if you follow the tutorial, You need to change the port number

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8080);

console.log('Server running on port 8080.');

Just change the 8080 to something different to prevent any conflict with WAMP, XAMPP, UNIZero and others.

test on port 9999, then type on your browser http://localhost:9999. By setting it up like this you can still use the http://localhost/ for your PHP server.

This is how I set my development servers Apache port 80; Nodjs port 92; Python port 95

veedeoo 474 Junior Poster Featured Poster

Here is how you can start in 10 minutes or less. (Windows)

1 - 3 minutes : download and install your flavor.

4 - 5 minutes : open command prompt assuming your installation is on windows and on c drive. cd to the nodejs directory

C:\>cd nodejs

hit enter and then type

 C:\nodejs>node
 >

let's exit for a moment by pressing ctrl + c twice to go back to nodejs directory.

6 - 10 minutes : create a new file test.js in C:\nodejs\test.js. Copy and paste codes below and save your changes.

console.log("Welcome to my first NodeJs Program");

go back to your terminal and type

C:\nodejs>node test.js

hit enter and you should get something like this

C:\nodejs>node test.js
Welcome to my first NodeJs Program

In addition to cereal's recommendation read this great tutorial. Read the Doing Something Useful - HTTP Server paragraph.

Once you have immersed with the syntax, try reading Doing Something Useful - Express it is about the express framework. Make sure to always follow these simple protocols and you won't get lost.

Practice and read Pro Node.Js for Developers from Appress written by Colin J Ihrig, Andy Ihrig.

cereal commented: good suggestions! +13
veedeoo 474 Junior Poster Featured Poster

That's pretty cool Diafol.

For people who have php version 5.3.7, they can use password_compat .

Before forgetting the purpose of my response, I think it would nice if you can add password_needs_rehash.

The same is true for the people who maybe using password_compat. When the PHP version is upgraded to 5.5, then the password_compat needs to call the password_needs_rehash method.

thank you for reading you guys :) :)

diafol commented: nice ideas +15
veedeoo 474 Junior Poster Featured Poster

you can read a good tutorial here. Please let me know if it help.

I can write you the codes, but I am in middle of doing very important projects right now. Maybe later,I'll have to see..

veedeoo 474 Junior Poster Featured Poster

are you talking about this thread?

veedeoo 474 Junior Poster Featured Poster

You can use ffmpeg PHP, but make sure you have ffmpeg installed on your server. Not until then, I won't be able to give you my response. Yes, it can be done in PHP.

If you want to go ahead, search for ffmpeg concatenation option.

RikTelner commented: Cool. Was unaware of that. +2
veedeoo 474 Junior Poster Featured Poster

Hi,

try this first.. create a file index.html and save to photos/

If it does not do the trick, you can define directoryIndex directive in .htaccess file.

create .htaccess file and then paste codes below

DirectoryIndex index.html index.php index.cgi index.inc index.tpl index.htm

If you are serving your site on VPS, you can define directoryIndex directive when you create your virtualhost.

<VirtualHost *:80>
    ServerName *.yoursite.com
    DocumentRoot "putyour stuff here as directed by your host"
    DirectoryIndex index.html index.htm index.php index.tpl index.cgi
</VirtualHost>

Lastly, you can also do this in your apache httpd.conf file

<IfModule dir_module>
DirectoryIndex index.html index.shtml index.html.var index.htm index.php3 index.php index.pl index.cgi
</IfModule>

the above will need the dir_module enable

change this (httpd.conf)

#LoadModule dir_module modules/mod_dir.so

to this

LoadModule dir_module modules/mod_dir.so
veedeoo 474 Junior Poster Featured Poster

@ashokkmr22

Is it twice or 4 times bigger than my database? Or, is it ten times bigger?

52ec7571e68051e6836fb4631c58c30d

I use MyISAM because I want a lock per session so that no other session can request while the current session hasn't finished. I prefer MyISAM in some project because of its speed and full text indexing. Otherwise, my first choice will be innoDB.

InnoDB is also good if you want to do transaction where several requests can be handled as one. You can either apply or revert on the InnoDB. InnoDB is capable of row locking and micro locking mechanism.

Innodb is being updated regularly while MyISAM is now almost to being neglected.

veedeoo 474 Junior Poster Featured Poster

I was looking at a similar database yesterday.

You can read here, and here . Left and right is on part 2.

veedeoo 474 Junior Poster Featured Poster

If you want a host that is managed from Silicon Valley area, try certified hosting. I think they are good with shared hosting.

For VPS, I was pretty satisfied with inmotion and rackspace. For multimedia hosting and RTMP red 5 servers Go for the red5hosting.

Cirtex own the cloud VPS host named HostV. Take hostV, but don't bother with the cirtex shared hosting. Their bandwidth and server resources meter is not that accurate. I had a really nasty arguments with this people.

Stay away from Apthost and greengeeks. If the owners of these two hosting companies are reading this, please send me a PM and I will tell you why guys sucks.

veedeoo 474 Junior Poster Featured Poster

Can you please show us the source codes of the page in question?

Thanks.

veedeoo 474 Junior Poster Featured Poster

It depends on what type of script you want to run in the background. You need to give us more information. Speculation is not a good thing.

veedeoo 474 Junior Poster Featured Poster

You can make the PHP QR code as joomla extension. To be able to do this, you need to follow simple rules as shown here. Pick which example is the closest to your intended application.

veedeoo 474 Junior Poster Featured Poster

I experimented with live streaming when I was in High School. The idea was to use a webcam then send the video accross the web through Red5 and Wowza servers. Today, they already have a much reliable servers that can do RTMP.

Just to give you the idea on how we did it 9 years ago. We utilize ffmpeg php and we lowered down the bitrate almost equal to the bitrate requirements of the Ogg video about 75kbps which is intended for 3inches x 3innches window. The result was cool even on 56k modem, but never liked the grainy video. We waited for a much cheaper high speed connection, but it never came. It was just too expensive for high school students to afford the monthly payment for the cable internet services.

Slowly, we abandoned the project after the interests have completely deminished, because all of us were bound for college.

I honestly believe that you can do this. If we were able to achieved similar to this some 9 years ago, there should not any problems doing it this time.

With a lower bitrate, ffmpeg PHP can capture the images and save it some directory. You can use the captured images and for face recognition jquery plugin. Since the processors of today are 50x faster than when I was in high school, I don't see any problem with the ffmpeg re-transcoding everything back to video.

veedeoo 474 Junior Poster Featured Poster

Your first attempt was fine for me.

Why is it fine for me?
The $cron_id has nothing to do and it is not part of the query. So, whatever the value of the cron_id, it will not affect nor change the delete query. It may change the frequency of executing the query, but it has no controll on what to delete.

The query that will definitely require a bind_param is something like the scenario on my example below.

For example, we have a user interface that allow user to select and delete their personal files.

Based on the requirement of the interface, there will be user input involvment here. Let say the user click on the link below

<a href="delete.php?id=102"/> delete this item </a>

the delete.php can be coded like this

<?php

    if(isset($_GET)&&(filter_var($_GET['id'],FILTER_VALIDATE_INT))){

        $file_id =  filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);

        ## the bind parameter
        $stmt = $mysqli->prepare("DELETE FROM user_files WHERE file_id = ?");
        $stmt->bind_param('x', $file_id);
        $stmt->execute();
        $stmt->close();

      }
veedeoo 474 Junior Poster Featured Poster

Have you heard about join optimization?. Try doing joins first and see if it will help.

veedeoo 474 Junior Poster Featured Poster

You cannot just do this

 <?php
    if(isset($_POST['filed'])){
    rename($_POST['file']);
    }
?>

and expect for the magical moments to occur. The reason I have provided you with the link above is for you to use them as reference and to learn more about them.

the rename function syntax is like this

rename("directory_where_file_is_located/name_of_the_file_to_be_rename.ext", "directory_where_the_renamed_file_is_to_saved/new_name_of_the_file.ext");
veedeoo 474 Junior Poster Featured Poster

by the way, you don't really need to do this

 $query= $this->db->get('');

this should be the proper way

 $query= $this->db->get();

the reason is that the database active record class method for get is declared like this

public function get($table = '', $limit = null, $offset = null)

What does the above method tells us is that the parameter table has been predefined as '' as empty, while the $limit and the $offset parameters are predefined as null.

I know this bring up many arguments about all the parameters are equally the same. In theory, they may appear to be equal but the null will return false if evaluated if it is set, while the '' or "" will definitely return true. However, the most revealing truth that these 3 parameters are not equally the same at any point is this. If '' or "" is evaluated as is_null() it is definitely false, but all will evaluate to true if evaluated as empty(). Whereas in the comparator operators, these three will also have a hair line difference. Null is true if compared as == and ===, while '' and "" will become false in === and true in ==.

That is pretty important stuffs in dealing things in Obejcts and methods. So, we don't really do this

if($query->num_rows()== 1)

the reason is that the numerical rows carries a default value of 0 ONLy in this regards, so if we do this

if($query->num_rows()> 0)

that …

veedeoo 474 Junior Poster Featured Poster

can you change and test your model with this code?

function get_detail($Product_ID)
{
    $this->db->from('products');
    $this->db->where('Product_ID',$Product_ID);
    $query= $this->db->get('');
    if ($query->num_rows() >0 ) {

    return $query->result();

    }

     /// return false;
}

this

return $query->result();

allows you to access the $row in view as object.,

while this one will allow you to index the array e.g. $row['column_name'].

    return $query->result_array();
veedeoo 474 Junior Poster Featured Poster

ok, use your good command in html and css. Create an html document something like this

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <link rel='stylesheet' type='text/css' href='style.css'/>
    </head>

    <body>

        <div>Make this disapper on click using jquery</div> 

    </body>
</html>

create the style.css and make the <div> with blue background; widht: 400px; and height: 400px;

Write a jquery function to make the div fadeout on click. I want you to make the fadeout slow.

veedeoo 474 Junior Poster Featured Poster

I assume that you don't help past donors as much as new donors. But yeah, good points! ^^

I do help all regardless. However, I must confess that most of the time my enthusiasm to help is more intense with the donors, but I can also feel very lazy some of the time. Other than my personal preferences, the quality of help is pretty much the same. I am more concern of the quality of help I can provide.

veedeoo 474 Junior Poster Featured Poster

can you do ?

print_r($data['row']);
veedeoo 474 Junior Poster Featured Poster

I look for all of the above and these as my own personal rules (some are maybe redundant)

  1. Ask for help rather than demanding for help.

  2. Asking us to write the codes for you is a big NO! and another NO!. We can provide one if we feel like writing one for you.

  3. Trim those newbie pride of yours. "I am a seasond developer and I know what is going on." kind of statements will not get fast response. The reason is simple. If you truly know what is going on, then what in the world you are needing help. Where I'm coming from, when we assumed the title of a PHP developer, we are it and the buck stops right in front of us. We solve our own misery by intensive research. Plus, you might intimidate new developers who might know the best anwser to your question.

  4. Be thankful and be respectful to volunteers. Sometimes, a little dub of grease can get volunteers inspired and may give you more than what you asked for. If this your case, considered it one of your luckiest day.

  5. Do not post codes that are not relevant to the problem. Some members will post the entire application source codes.

  6. Do not ask questions about your school project 5 days before the deadline. Waisting the entire semester until 5 days before it ends does not make sense to me. You need to try a little harder. It is your grade and not ours.

  7. If …

mattster commented: Well said. +5
matrixdevuk commented: Agreed 100%. +2
veedeoo 474 Junior Poster Featured Poster

In my opinion, you should create a database design flow similar to what diafol have given above and from the design flow, you create the tentative database table.

The next step is visualization of your design. Once you are satified, create the actual database and add test values. The next step is query testing. The tools that I am currently using in testing proposed database is called "MysQL Workbench" which offfers database visualization, editing, query optimization, data modeling and many other cool stuffs.

A tentative database table can be something like below. A design flow is something like Diafol gave us.

exam table

exam id ( this will be an auto-incremented value)
class id
exam id
exam time
exam duration
exam type ( pre-lim, med-term, finals)
instructor assigned (use instructor id)

class table

class id (auto-incremented)
class description
class section
class instructor id
class term (winter ? spring ? summer ? fall)
class passing grade ( in percent)

instructors table

instructor id (auto)
instructor name
instructor last
instructor dept
instructor total hours
instructor total class
assigned exams ( the number of assigned exams to monitor)

instructors time table

 asignment id (auto)
 instructor id ( derived from the instructor table)
 instructory total assignments ( how many exams this instructor must give)

 time of assignment begin (time when the instructor must be in the class room)
 time of assignment end ( time when the exam will end)
 total time needed for this assignment( the sum of …
veedeoo 474 Junior Poster Featured Poster

add the extension to

$imagetype = array( 'bmp', 'gif', 'jpg', 'jpe', 'png');
$file_type = array('txt','html');

PHP file should not be allowed to be upload in your server due to security reason.

find what is the extension of the upload and then check if it is an image or a file. If image use the image validation on your script, if it is a file validate the file accordingly.

veedeoo 474 Junior Poster Featured Poster

You can use either one

rename

copy

veedeoo 474 Junior Poster Featured Poster

We can be a little conservative by splitting them in sequences using substr PHP function.

 ## we need to set everything as string first  
 $str = 'ab5611571608318077634568';

 ## validate if the entire string is 24
 if(strlen($string)== 24){

 ## get the first two
 $first_two = substr($string, 0, 2); //returns ab
 ## validate here if first_two are letters only

 ## get the third and the fourth for your number validation
 $numbers = substr($string, 2,2); //returns 56
 ## validate here if $numbers are anything between 0 - 9

 ## get 20 characters from the right returns 11571608318077634568
 $twenty_numbers = (substr($string,-20));

 ## validate here if twenty_numbers are numeric 0-9

 }

Use regex validation as suggested by Pritaeas.

veedeoo 474 Junior Poster Featured Poster

I couldn't find the thread here on Daniweb. It was from 2 or 3 years ago. I am relying here on my memory and I think it was the column 'caldesc', but it could have been 'description'.

Can you double check and make sure that all of your database columns matched with the database query and query results?

so for example if we have

 $title = $row['caltitle'];
$desc = $row['caldesc'];
$loc = $row['callocation'];

then those columns should exist as

+ caltitle + caldesc + callocation +
+----------+---------+-------------+
+          +         +             +
+----------+---------+-------------+

Here is another calendar you may want to take a look.

For this type of function, I normally use libraries e.g. CodeIgniter Calendaring Class and calendar plugin for Symfony2. So, there are pretty people would write this script from the ground up.

veedeoo 474 Junior Poster Featured Poster

I am new to yii and php and i want to deleveop a database design for school exam time table and maintain the time table for school management. How can I procced the same?

If you are new to PHP and PHP MVC framework like yii, I don't see any reason for you to be developing any application in this type of framework environment.

Please don't take my statement personally. I am just trying to be honest and trying to save you from gargantuan headaches.

veedeoo 474 Junior Poster Featured Poster

Another question, was the original tutorial uses regular mysql extesion or was it MySQlI as shown on your codes. May I see the original sourcecodes or the tutorial page?

veedeoo 474 Junior Poster Featured Poster

did you fill this up properly?

$conn = mysqli_connect("Thanks","for","all the","fish")

mysqli connector syntax is like this

$conn = mysqli_connect("db_host","db_user_name","db_user_password","datbase_name") or die("Error " . mysqli_error($link)); 

I remember a similar question was asked some two years ago. It has something to do with the database columns.

veedeoo 474 Junior Poster Featured Poster

These are just my humble suggestions and no way it comes with any guarantee of the same results I have achieved using these methods.

In addition, you can also learn it from Zend, the people who are responsible and the inventor of Zend Scripting Language Engine and making PHP the fastest evolving programming language of all time. Use the regular WAMP or LAMP stack and don't use the zend server for now, believe me it can overwhelm anyone new to PHP. Start slow, but make sure to aim higher like the Objects and Methods, then to design patterns. Hopefully, by 8 months or so, you can start testing the PHP MVC design patterns.

Some part of their site offers a PHP certification, if you have money to burn, go for it. You can also buy some PHP books from O'rielly and Apress as a supplemental desktop reference.

If you ever fell in-love with the Zend and would like to become a certified Zend Engineer, then you can also take this great, but costly opportunity.

Remember, the courses for both of the certifications above are very costly, at least for me. I took the course when I was in High School and I was able to fund the course and the books from my school allowance and from my little income delivering Los Angeles Times news paper every morning. The test vouchers cost was a lot cheaper than the course.

Good luck on your study..

veedeoo 474 Junior Poster Featured Poster

Your codes will work perfectly, just make sure to put a default page on it, or wrap it with

if(isset($_GET['tab']){ 

    //codes here

   }

to avoid getting the undefined variable error.

Mine will probably work best if there is a function or method involve in the process, but I am not sure because I didn't even try testing it.

veedeoo 474 Junior Poster Featured Poster

The above class can also be use in Smarty and other template engines that don't have any form generator. Below is a classic example if we are to do it on smarty..

Controller file or any simple PHP file..

$smarty->assign(
                array(
                      'form_open' => $form_create->form_option('post', 'processor.php', 'myform', 'coolform'),
                      'name_label' => $form_create->form_label('Name', 'name'),
                      'name_input' => $form_create->form_input('text', 'name', '', 'input_class', 'type your name here'),
                      'lang_label' => $form_create->form_label('Select Language','lang'),
                    'lang_select' => $form_create->form_select($select_array,'language'),
                    'form_submit' => $form_create->form_submit('submit', 'Submit', 'submit_button', 'submit'),
                    'form_close' => $form_create->form_close()

                    )
                 );  

template file

{$open_form}

{$name_label}

{$name_input}

<br/>

{$lang_label}
{$lang_select}

<br/>

{$form_submit}

{$form_close}
veedeoo 474 Junior Poster Featured Poster

The purpose of this class is to be able to create an html form with ease. This is inspired by the form helper in CodeIgniter. This can easily adapt to bootstrap or any css and jquery where id is required.

To use this class, we need to include the class provided below.

require_once('FormHelper.php');

## we create an instance of the class
$form_create = new FormHelper();

we can also dynamically create <select>, by defining the option items as an array

$select_array = array('php','java','html','javascript','python','perl','jquery');

generate the form

echo $form_create->form_option('post', 'processor.php', 'myform', 'coolform');
echo $form_create->form_label('Name', 'name');
echo $form_create->form_input('text', 'name', '', 'input_class', 'type your name here');
echo '<br/>';
echo $form_create->form_label('Select Language','lang');
echo $form_create->form_select($select_array,'language');
echo '<br/>';
echo $form_create->form_submit('submit', 'Submit', 'submit_button', 'submit');
echo $form_create->form_close();

the above should give us this output

<form method="post" action="processor.php" id="myform" class="coolform">
<label class="name" id="">Name</label>
<input type="text" name="name" value="" class="input_class" placeholder="type your name here"/>
<br/>
<label class="lang" id="">Select Language</label>

<select name="language">
<option value="php">Php</option>
<option value="java">Java</option>
<option value="html">Html</option>
<option value="javascript">Javascript</option>
<option value="python">Python</option>
<option value="perl">Perl</option>
<option value="jquery">Jquery</option>
</select>
<br/>
<input type="submit" name="submit" value="Submit" class="submit_button" id="submit"/>
</form>

How to handle the parameters in methods?
Let's take this method as an example

form_input($type, $name, $value = null, $class = null, $placeholder = null)

$type and $name are mandatory, while $value, $class, and $placeholders are not even required. However, if we want to add placeholder, we cannot just put our placeholder parameter after the $name parameter, instead we need to place an empty values for the $value and $class.

 echo …
diafol commented: nice work +15
veedeoo 474 Junior Poster Featured Poster

I like the way how one ask his question. He reminded me of the Bicentennial Man my favorite movie when I was a kid.

To answer one's question, one should find the extension of the file and then based on the file extension one should execute a function to do whatever one's wishes.

veedeoo 474 Junior Poster Featured Poster

The way you can do this fast and easy is something like this

before the submit button validation, define all the errors like this

<?php

    $title_error = '';
    $forename_error = '';
    $surname_error = '';
    ## do the same for all of the items needing validation

    ## check if the submit button is set

    if(isset($_POST['submit'])){

        if(!empty($_POST['title']){
            $title = filter_var($_POST['title'], FILTER_SANITIZE_STRING);
        }

        else{

            $title_error = 'Title is required';

           }
     }      

You do the same for the remaining and on the html form you do like this

 <input type="text" name="title">
 <span><?php echo $title_error;?></span>

You can style the <span> with css. It is all up to you.

There is another method of form validation, but it is more complex and maybe you guys can take a look at it. It is called filter_input_array(), you can read on how this function is used in form validation.

veedeoo 474 Junior Poster Featured Poster

Will this be good?

How about this? It is two years old, but I think it should work with minimal upgrades.

veedeoo 474 Junior Poster Featured Poster

Does the number of if conditions really make changes to the performance of the page?

probably, nobody ever study the performance of a nested if statements. Nesting them too deeply we will have the so called "spaghetti logic" , but there is hope and I can assure you it is highly recommended to use switch.

Should I switch to separate page and have visual tab look?

Have you heard about the PHP function called file_get_contents()? This can be something you want to investigate and it is binary safe.

example:

<?php 

$content1 = 'this is content one';
$content2 = 'this is content two';
$content3 = 'this is content three';
$default_content = 'This is default content';


if(isset($_GET['content']) && (!empty($_GET['content']))){

    $x = $_GET['content'];

switch ($x){
    case "content_one":
    $content = $content1;
    break;

    case "content_two":
    $content = $content2;
    break;

    case "content_three":
    $content = $content3;
    break;

    default: 

    $content = $default_content;

}

}
else{

    $content = $default_content;

}

## tabs
    echo '<h2> My PHP tab </h2>';

    echo '<a href="?content=content_one"> [ Content 1 ] </a>  |  <a href="?content=content_two"> [ Content 2 ]</a> | <a href="?content=content_three">[ Content 3 ]</a>';

    echo '<br/>';

    echo $content .'<br/>';

These

$content1 = 'this is content one';
$content2 = 'this is content two';
$content3 = 'this is content three';

can take pages like this

$content1 = file_get_contents('content1.txt');
$content2 = file_get_contents('content2.txt');
$content3 = file_get_contents('content3.txt');

to make it to work effeciently, you need to change the execution on the switch side and get rid of the above e.g.

case "content_one": …
veedeoo 474 Junior Poster Featured Poster

where is the "group_level" in your form?

this will always be empty

 $group_level = isset($_POST['group_level']) ? $_POST['group_level'] : '';

because it will never evaluates to true and you've sets expressions setting everything with empty values by default.

 // set all empty for new info
    $group_id = "";
    $group_date = "";
    $group_name = "";
    $group_package = "";
    $group_level = "";
    $group_teacher = "";
    $group_payment = "";

you add something like this in your form

<input type="text" name="group_level">
veedeoo 474 Junior Poster Featured Poster

create a new file, put paste codes below, and save as whatever.php in wamp/www directory

<?php

    echo 'Hello, are we there yet?';

direct your browser to http://localhost/whatever.php, voila your first PHP page.

veedeoo 474 Junior Poster Featured Poster

here is the link of a constantly updated version .