broj1 356 Humble servant Featured Poster

This could be quite a complex task and I think you would need some server side scripting (such as PHP) and a database (like mysql). You would also have to look at the PHP forum here but I guess you might get some experience or get someone with PHP and mysql skills to help.

BTW, Moodle is a popular opensource ready-made environment for e-leraning. Would it not cover your needs?

broj1 356 Humble servant Featured Poster
// $_SESSION['receiver_id'] = 'receiver_id'; <- here need to be ?

This should be between lines 16 and 17 (after querying the database, and uncommented). Or maybe outside this function altogether.

broj1 356 Humble servant Featured Poster

Sorry, have been quite busy lately.

To store the receiver_id into a session variable you only have to read it from the database and assign it to a session variable:

$_SESSION['receiver_id'] = $row['receiver_id'];

But I am not sure if this is useful for you to also store the receiver in the session. Depends on the logic of your app.

broj1 356 Humble servant Featured Poster

PHPClasses has many examples of ready made classes covering various functionalities. A great way of learnig some advanced stuff (by examining the code).

broj1 356 Humble servant Featured Poster

Maybe there is something wrong with your update query (maybe the $sender or $total are not what you expect). You can simply check it by sticking the following piece of code right after line 24:

die($query);

This will display your update query with the parameters and stop the script. Now you can copy the query into phpmyadmin and check if it returns any data.

broj1 356 Humble servant Featured Poster

Haven't studied your code closely but the number 2147483647 is exactly the max integer value on 32 bit systems. Why do you not handle your phone number as a string?

broj1 356 Humble servant Featured Poster

Welcome to Daniweb. Please read this sticky.

This is the first hit from duckduckgo search:

http://www.plus2net.com/php_tutorial/php_forgot_password.php

and there are heaps of others. You can find a lot of useful stuff regarding your question on this forum, too.

broj1 356 Humble servant Featured Poster

The simplest way is to enclose the whole html table within a form. In each row there is a delete button which is actually an input element with a type="submit". The name attribute of each delete button should be a corresponding ID of the row in the database (typicaly a primary key by which you address the row to be deleted). So hitting a delete button will trigger a request and send the ID of the row to be deleted in a $_POST (or possibly a $_GET but not recommended). All you need in a deleting part of the script to fire a DELETE SQL statement to the database.

The disadvantage of this approach is in that the page gets refreshed on each delete which might be not that user friendly if you wish to delete many rows quickly. Other solutions are to have a checkbox in each row and one delete button for the whole html table or to use Ajax (so the rows get deleted behind the scenes).

Edit: Ajax, as Diafol already suggested above :-)

broj1 356 Humble servant Featured Poster

@imti32: sorry, I meant method (as noted in the text of the post). Correct code is:

<form method="post" id="nl-form" class="nl-form" action="../EMAIL.php">

Thanx for spotting, mate :-).

<M/> commented: Thanks :) +10
broj1 356 Humble servant Featured Poster

I had a quick look at the code and the main error is that you are missing a method attribute in the form, so it defaults to GET, but you are using POST parameters. So change the form line to:

<form action="post" id="nl-form" class="nl-form" action="../EMAIL.php">

There are other errors too, like:

  • if your document is of html5 type then you do not need to use / for closing tags of elements
  • you can not use em tag within the input element, you can style the placeholder using css as shown here
  • the starting div for the container is missing
  • some other missing variables but this might be due to some missing code in your post
<M/> commented: Thanks :) +0
broj1 356 Humble servant Featured Poster

I'll do a bit of guessing here since I do not have experience with MS SQL server. It seems that MS SQL support is not installed in your EasyPHP environment (default is mySql). There is some info on this link on how to do it.

broj1 356 Humble servant Featured Poster

If you do not have image ID then $data array is not set. You should check for it before using it, especially in these two lines:

if(isset($data['image']) && isset( $data['newfilename'])) {
    echo $data['image'];
    echo '<div id="updateimage"><img src="images/'.$data['newfilename'].'"  height="250px"></div>';
}
broj1 356 Humble servant Featured Poster

I presume the above code is not the form you want but some example you found somewhere. Following your description this is how I would code it:

<?php 
// define checkbox data here
// (you might read it from the database)
$inicidentData = array(
    1 => 'Incident data 1',
    2 => 'Incident data 2',
    3 => 'Incident data 3',
    4 => 'Incident data 4',
    5 => 'Incident data 5',
    6 => 'Incident data 6',
    7 => 'Incident data 7',
    8 => 'Incident data 8',
    9 => 'Incident data 9',
    10 => 'Incident data 10',
    11 => 'Incident data 11',
    12 => 'Incident data 12',
    13 => 'Incident data 13',
    14 => 'Incident data 14',
    15 => 'Incident data 15'  
);

// check if user clicked the submit button
// you do all the processing on this same page (you could also do it on another page)
if(isset($_POST['submit'])) {
    // you would save this to a database but we will do that 
    // in next step once you are happy with the form
    // for now lets just display what was selected
    echo '<pre>';
    print_r($_POST);
    echo '</pre>';
    exit();
}
?>

<form id="form_919443" class="appnitro" method="post" action="#">
<div class="form_description">
<h2>Incident report</h2>

<div>You are logged in as: <?php echo $UserName; ?>derp</div>

<label class="description" for="incident-number">Incident number</label>
<input id="incident-number" name="incident-number" class="element text medium" type="text" maxlength="255" value=""> 

 <ul>
 <?php 
 // generate checkboxes using php
 foreach($inicidentData as $inKey => $inData) {
     echo '<li><input type="checkbox" name="incident-data[]" value="' . $inKey . '">' . $inData . '</li>';
 }
 ?>
 </ul>

 <input …
JorgeM commented: Great job on your examples and explanations. +12
broj1 356 Humble servant Featured Poster

Seems like some obfuscated php code. The author probably did not want others to see it without a lot of effort. Might be connected to the copyright notice in the beginning of the script.

broj1 356 Humble servant Featured Poster

I have tested your script and it works OK. This is the data I tested on:

INSERT INTO book (id, bname, aname, pname, description) VALUES 
(1, 'Book 1', 'Author 1', 'Publisher 1', 'Description 1'),
(2, 'Book 2', 'Author 2', 'Publisher 2', 'Description 2'),
(3, 'Book 3', 'Author 3', 'Publisher 3', 'Description 3'),
(4, 'Book 4', 'Author 4', 'Publisher 4', 'Description 4')

To make sure form submits to the same page I changed line 8 to:

<form action="#" method="POST">

What you can do is you can put an echo line just below line 54 and check what queries get generated:

echo "$sql<br>";
broj1 356 Humble servant Featured Poster

You don't have to be offended so quickly. I never said that I am better in PHP than you and I don't care about that anyway. And I was not studying your profile to better understand your question since this is not how this or other forums work. Based on your question which was very broad and a bit hard to understand I just tried to point you in a right direction on what to search. If you studied my profile you would have seen that I often put a lot of effort into helping others and I never tried to put people down. It's just not my style.

Anyway, have you read the guidelines on how to ask a question to get a good answer? Following this might get you to the solution much quicker.

Now, if you are asking a question about accounting stuff, I have no clue about that and really can not help here.

broj1 356 Humble servant Featured Poster

Repeating: You should put the session_start() command on top of the every script for session to work.

broj1 356 Humble servant Featured Poster

You should put the session_start() command on top of the admin.php script for session to work.

broj1 356 Humble servant Featured Poster

This is a rough code (might need some tuning):

// temporary array for reading data into
$tempArray = array();
$result = $mysqli->query("SELECT * FROM portraits ORDER BY category");
while ($row = $result->fetch_row()) {
    $category = $row['category'];
    $tempArray[$category][] = $row['collection_name'];
}
// process the temp array
foreach($tempArray as $cat => $galeryArray) {
    echo "$cat: " . implode(' ', $galeryArray) . '<br>';
}

The idea is to read all the data inot a temp associative array where the associative indexes are category names and values are array of galeries. You will have to do some fiddling to construct links. I used mysqli in OO mode. Adapt if you use something else.

broj1 356 Humble servant Featured Poster

To follow good design practices you should keep categories in a separate table. But anyway:

  • put a select element (a dropdown) or checkboxes on page to let people chose a category/ctagories
  • create a select statement using a chosen category/categories construct a SQL statement to query the database:

    $query = "SELECT * FROM portraits WHERE catgory = $chosenCategory";

Then just display resulting rows in a form you think is appropriate (i.e. looping through a resultset using a while loop).

broj1 356 Humble servant Featured Poster

In 2.php you should have details enclosed within an html eement (such as div) with an ID so that you can access it using jquery text() or html() or similar method.

<div id="my-content">
This is the body of the email.
</div>

var emailBody = $("#my-content").text();
broj1 356 Humble servant Featured Poster

First store the username in the session variable.

// sanitize/validate first
//...
$_SESSION[$uname] = $uname;

On other pages (within the same session) it will be available to your scripts:

$uname = $_SESSION[$uname];

provided that you used the session_start() (always put it on top of your script).

And sanitize the user input first using appropriate method depending on where are you using the data (database, email, html, url, javascript...).

broj1 356 Humble servant Featured Poster

So you have to make sure the database collation is the right one and also that the DB connection collation is OK (in mysql utf8_unicode_ci is pretty safe). Also you can use this query upon connecting:

SET NAMES utf8

In HTML it is good idea also to set a meta tag:

<meta charset="UTF-8">
broj1 356 Humble servant Featured Poster

Seems to be possible doing this using Javascript. See http://msdn.microsoft.com/en-us/library/office/fp161148%28v=office.15%29.aspx. And use PHP to pepare the HTML part.

broj1 356 Humble servant Featured Poster

If you replace the following code:

list($ip, $netmask) = split("/", $ipNetmask );
$ip_elements_decimal = split("[.]", $ip );

with this one (for IPv4 addresses):

list($ip, $netmask) = explode("/", $ipNetmask );
$ip_elements_decimal = explode(".", $ip );

you should not get the depreciated notice. In fact I think you do not need regular expressions (with their overhead) for this.

broj1 356 Humble servant Featured Poster

If I got your question right you want to know whether a special character is required in PHP to write a statement on multiple lines. The code in PHP would be:

$query = "INSERT INTO table(field1," .
"field2)VALUES(value1," .
"Value2)";

or

$query  = "INSERT INTO table(field1,";
$query .= "field2)VALUES(value1,";
$query .= "Value2)";

or simply

$query = "INSERT INTO table(field1,
field2)VALUES(value1,
Value2)";

You use a dot (.) to concatenate strings or use any whitespace (line break, spaces) within a string to format the code.

diafol commented: That was my take as well +15
broj1 356 Humble servant Featured Poster

If you know the structure will be exactly like the above:

function convertDate($oldDate) {
    $months = array('Jan' => 1,'Feb' => 2,'Mar' => 3,'Apr' => 4, 'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8, 'Sep' => 9, 'Oct' => 10, 'Nov' => 11, 'Dec' => 12);
    $temp = explode('/', $oldDate);
    return $temp[2] . '-' . $months[$temp[1]] . '-' . $temp[0];
}
arafath077 commented: thanks.itz worked +0
broj1 356 Humble servant Featured Poster

You have 5 rows of select element and checkboxes so you have to keep track of which row a user has selceted / checked. You can do this if you add row number to the name attributes. So for row No. 1 the attribute would be:

<select name="lang[1]">
<input name="speak[1]" type="checkbox" value="yes" />
...

The easiest way to keep the code manageable is to store languages into an array and then loop through this array and construct all the elements. here is my version of code:

// array of languages
$languages = array(1 => 'Hindi', 2 => 'English', 3 => 'Tamil', 4 => 'Telugu', 5 => 'Kannada');

// the form
// note the action has been set to # to test the output
// adapt this to your needs
echo '<form method="post" action="#">';

// table head
echo '<div align="center">
  <table width="434" border="0">
    <tr>
      <td>Languages Known</td>
      <td>Speak</td>
      <td>Read</td>
      <td>Write</td>
      <td>Delete</td>
      </tr>';

// table rows
for($i = 1; $i <= count($languages); $i++) {
    echo '<tr><td>';

    // select element
    echo '<select name="lang[' . $i . ']">';
    echo '<option value="0">- Select -</option>';
    foreach($languages as $key => $lang) {
        echo '<option value="' . $key . '">' . $lang . '</option>';
    }
    echo '</select></td>';

    // checkboxes
    echo '<td><input name="speak[' . $i . ']" type="checkbox" value="yes" /></td>';
    echo '<td><input name="read[' . $i . ']" type="checkbox" value="yes" /></td>';
    echo '<td><input name="write[' . $i . ']" type="checkbox" value="yes" /></td>';

    // delete button
    echo '<td><input type="button" name="button5" id="button5" value="Delete" onclick="delete(this)" /></td>';

    echo '</tr>';
}
echo '</table>';
// submit butoon …
broj1 356 Humble servant Featured Poster

This bit of code seems to be OK. Are you sure that this is the line that is causing the error? Sometimes an error can occur a number of lines before. Maybe you post more code.

broj1 356 Humble servant Featured Poster

On lines 26 and 27 you assign strings to $uname and $pword variables:

$uname = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS);
$pword = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_SPECIAL_CHARS);

On lines 38 and 39 you assign values to the $_SESSION but now you treat the above strings as arrays:

$_SESSION['User'] = $uname['username'];
$_SESSION['Passw'] = $pword['password'];

To me logical code would be:

$_SESSION['User'] = $uname;
$_SESSION['Passw'] = $pword;

except if you had something else in mind?

broj1 356 Humble servant Featured Poster

Maybe line 23: while($row=$result->fetch_assco()){...

It should probably be:

while($row=$result->fetch_assoc()){...

assoc stands for associative; this method returns a row in an associative array where field names are keys.

broj1 356 Humble servant Featured Poster

It is a lot of code but as it seems the $image[photos] is an array of photos that you should iterate through, something like:

foreach($cleaned_response as $image){
    foreach($image[photos] as $oneImage) {
        echo'<img height="100" width="100" src="'.$oneImage['fullsize'].'"/>'
    }
}
broj1 356 Humble servant Featured Poster

If you want to sort using php then you have to:

  1. convert javascript array (of arrays) into php array using json_decode function
  2. sort the php array using array_multisort function

This is the code, see also comments in the code:

// this is original string representing a javascript array of arrays (note square brackets arround your string)
$jsonString = '[[1366754400000, 8], [1366840800000, 3], [1366927200000, 1], [1368482400000, 1], [1384383600000, 1], [1369951200000, 1], [1377554400000, 1], [1377813600000, 8], [1380232800000, 4], [1381960800000, 4], [1382914800000, 6], [1384297200000, 6], [1384383600000, 1], [1386716400000, 2], [1389049200000, 5], [1392764400000, 3], [1393196400000, 1], [1397599200000, 4], [1398636000000, 2], [1401141600000, 1], [1401746400000, 1], [1409954400000, 1], [1410386400000, 5], [1371420000000, 25], [1377122400000, 1], [1386889200000, 1]]';
// convert json into php array
$arr = json_decode($jsonString);
// prepare temporary arrays for sorting
foreach($arr as $key => $val) {
    $times[$key] = $val[0];
    $values[$key] = $val[1];
}   
// sort the array using temporary arrays
array_multisort($times, SORT_ASC, $values, SORT_ASC, $arr);
// check the sorted array
echo '<pre>' . print_r($arr, 1) . '</pre>';

You can convert sorted php array back to javascript using json_encode function so you can use it in your javascript library.

broj1 356 Humble servant Featured Poster

Se the manual - the procedural style part. The mysqli_query expects two parameters, the link and the query. Similar goes for the mysqli_error. It expects the link in procedural version.

broj1 356 Humble servant Featured Poster

I tried that in begining, it execute 2 echo's for text and for = 0 so its like Points can't be text.Clean 0

What did you input to get these two echo statemens?

I tested my code and it works OK. It is important to have the exact series of if statements.

hey broj1, long time no seen, glad to see you!

:-) Thank you. Same here.

broj1 356 Humble servant Featured Poster

Why don't you do it simple way:

// first check if it is or isn't a number
if(!is_numeric($points)) {
    echo "Points can't be text";
// then try all possible values
} elseif($points == 0) {
    echo "Clean 0";
} elseif($points > 0 && $points <= 50) {
    echo "You did not pass";
} elseif($points > 50 && $points < 100) {
    echo "You passed test";
} elseif($points == 100) {
    echo "You finished with best result"; }
}

And beware: on line 20 you are using two variables for comparison: $points and $bodovi. Seems like a typo.

broj1 356 Humble servant Featured Poster

Nice job. Haven't tested the class but after scanning the code it is obvious that this is a nice example of clean coding / useful functionality. Quite some work must have been put into this to gather all the information an put it into this little tool. I remember myself struggling a couple of times needing to convert between formats.

Adding suppport for transparency might be also a very good idea.

Thank you for sharing.

broj1 356 Humble servant Featured Poster

Yes, I was a bit quick, sory. The thing is you want to use ajax to send a request to another php page which then sends a response which is a html code for a table containing results. You send a ServiceOrders category parameter along to use it as a filter in the query. Maybe the best would be to use the jquery post() method which sends a request along with the parameter and puts the response in the div you wanted. Mind you, the called php page does not have to have all the html stuff (like head tags etc) only the php code querying the database and echoing the html table displaying the results. Also I would use data in a JSON instead of string and I moved the script to the bottom of the html. I tested the code below and it works .

<!DOCTYPE html>
<html>

<head>   

<link rel='stylesheet' type='text/css' href='styles.css' />
<link rel="stylesheet" href="grid.css" type="text/css" />
<link rel="stylesheet" href="backgroundcss.css" type="text/css" />
<style>
form { width: 700px; }
label { float: left; width: 100px; }
input[type=text] { float: left; width: 200px; }
.clear { clear: both; height: 0; line-height: 0; }
.floatright { float: right; }

</style>
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
    <script type='text/javascript' src='menu_jquery.js'></script>
    <script type="text/javascript" src="jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>      
<script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });


 $(function() {
     $("#refresh").on("click", function() {
        $("#mydiv").load("http://192.241.175.69/ServiceOrderReport.php");
        return false;
    })
  })

</script>

</head>
  <body  class="container">
  <br>
<div id='cssmenu'>
<ul>
broj1 356 Humble servant Featured Poster

Depends on the situation. So the venueID and catID are from another table. You could code it this way:

...

  // add to array of WHERE clauses only if value is not FALSE
  if (${$field}) { 
      $wheres[] $field = venueID || $field = catID ? "$field='" . 'te_events.' . ${$field}."'" : "$field='" . ${$field}."'"; 
  }
}
...

The above code checks if the fields need to be prepended with the table name. But this code is not very flexible. Other approach would be to have select names contain table names (with dots) but I am not sure if this is valid in HTML:

<select class="select" name="te_events.catID" id ='catID'>
broj1 356 Humble servant Featured Poster

If I understood correctly you just want to skip first row which is heading row. If that is true then start inserting at row 2. Something like:

$heading = true;
while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
{
    // check if the heading row
    if($heading) {
        // unset the heading flag
        $heading = false;
        // skip the loop
        continue;
    }
    $sql = "INSERT into prod_list_1(p_bench,p_name,p_price,p_reason) values ('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]')";
    mysql_query($sql);
}
keshava_1 commented: Great its worked +0
broj1 356 Humble servant Featured Poster

Use one of the PDF libraries out there. I use tcpdf and am very happy with it. Find a function in your pdf library that deals with images. In tcpdf it is the Image() function (see an example here). You can either save the generated image to disk and use it in the Image() function or send the Image() function a base64 encoded string representing the image.

Mahesh_12 commented: Thanks.. I am following same idea but i am strugling to save the image can you explain how to save the image and how to get the saved image url +0
broj1 356 Humble servant Featured Poster

Newline in HTML is <br> tag (a break):

echo $row_selecttemptable['ArtistName'] . ' ,<br>' . $row_selecttemptable['NAMEOfTheDVD'];`
broj1 356 Humble servant Featured Poster

i want to know about php.net language?

php.net is actually a website (that incidentally tells you all about PHP).

Seems like you are new to this forum. Welcome and hope you will find it useful. And since your question is pretty general I suggest you read this article first which will give you some guidance on how to post. A well structured question guarantees quick response and a lot of hints to solve your problem.

broj1 356 Humble servant Featured Poster

The code on line 9 is wrong, it wont return what you expect. You could change your query a bit and ad AS to the substring expression in the query:

SELECT runners.raceid, SUBSTRING(runners.raceid,1,4) AS raceyear,...

and then change line 9 in the code to:

echo $row['raceyear'];
Borderline commented: Perfect result, many thanks! +3
broj1 356 Humble servant Featured Poster

phpacademy - learning by watching videos, various PHP forums like Daniweb :-), Stackoverflow, a good book on PHP, the documentation on the PHP.net site (comprehensive, free, but sometimes harder to get through it) and a lot of experimenting - set up LAMP or XAMP and go for it.

And do not forget other companion technologies: mysql, javascript, jquery, html, css etc. Happy coding in 2014.

broj1 356 Humble servant Featured Poster

I am just guessing (given the information I have) that on line 84 (and in other places) you are checking the session for existing username (logged-in user):

if (empty($_SESSION['MM_Username']))
{
    echo ("<h4>please log in before adding to shopping Cart</h4>");
}

If you want to enable guests to do the shopping, then you have to change the code for the empty username case:

if (empty($_SESSION['MM_Username']))
{
    // do whatever you intend to do only for guests
    // the rest of the code is equal as for logged-in users
}

i never did php lesson in classroom or any programmation lesson just introduction in programation

If this is true then it is a question if you are ready to program an online shop. Such a project demands quite a lot of skill and experience. Not that I want to put you off but keep in mind that you can get in trouble with your client if things do not work well and secure. Copying some code without understanding it will not help you.

broj1 356 Humble servant Featured Poster

You will need a secure application in any case if you intend to script online shop. To answer your question it is difficult since I do not know what functionalities exactly you would like. But in general if you use cookies to manage stuff realted to shopping cart, security is lower since cookies are on the client side and can be easily faked. Using sessions is safe. In reality you use a combination of both.

By default sessions store session data in the file system. You can change that so that session data is stored in the database which might be even safer. See this article.

Sory we could not find a solution for your problem. I think it was just a bit of missunderstanding. Maybe you should try to rephrase the question and post it again as a new thread so other people can jump in.

broj1 356 Humble servant Featured Poster

Remove the ) at thr end of the statement. Correct version is:

$userUpdateSQL = "UPDATE `database`.`table` SET usecolum='$hash' WHERE usercolum='$hash'";

I made a mistake and you copied it blindly :-)

broj1 356 Humble servant Featured Poster

@broj1 sorry, I didn't saw your answer, bye!

No worries, mate. Two answers are better than one :-)

broj1 356 Humble servant Featured Poster

To get the same hash use the same string for 30 days. There are many ways to accomplish this. One of them could be:

Initially:
- store the initial string for hashing in the users record in database
- set the cookie that expires in 30 days

Everytime you need a hash:
- check whether the cookie exists (has not expired)
- if yes use the string from the user record and hash it
- if no set new cookie with expiration 30 days, generate new string in user record in database and hash that string

Alternatively you can store a hash in the user record or store the date in the user record instead of the cookie (a cross-browser / cross-computer solution)