minitauros 151 Junior Poster Featured Poster

Looks as if you're simply providing a wrong username/password combination indeed.

minitauros 151 Junior Poster Featured Poster

If you are asking how to create a complete CMS, I'm afraid that's going to be too much to explain in just one forum post. There are numerous tutorials on the internet that explain step by step how you can set up PHP-MySQL websites and, with that, content management systems.

Secondly, you usually do not store HTML files nor images in your database, but instead you insert the path to the HTML files or images into it, so that you know which HTML files and images you need to load.

minitauros 151 Junior Poster Featured Poster

I believe there are multiple e-commerce management systems. There are plugins for Wordpress, but probably for Joomla as well. You have Magento, OpenCart, and probably numerous others. I suggest you google for something like "web shop management systems", "hosted web shop management", or anything like that.

minitauros 151 Junior Poster Featured Poster

First of all: do you get an error, or does the mail simly not arrive?

Second: you don't have to enclose the variables you pass to the mail() function in quotes. So:

mail("$sendto","$thesubject","$emessage","$eheaders");

could/should become:

mail($sendto, $thesubject, $emessage, $eheaders);

Third: your $thesubject variable does not seem to contain a value - it appears not to get set. Did you check this? I don't know if it's required to have it set, but well, you could try at the least if it makes a difference :).

minitauros 151 Junior Poster Featured Poster

First thing I see is that your code is a bit.. unexpected:

Your code:

if(isset($_SESSION['user'])== ' '){
    header('location:index.php');
    exit();
}

Should be:

if(!empty($_SESSION['user'])){
    header('location:index.php');
    exit();
}

as isset() returns a true/false value, and not a string like " " (to which you are comparing it now). I suspect that you are checking for the presence of a value in $_SESSION['user'] here, which is why it should be !empty() instead of isset() (isset() is ok, too, but I think you will want to use empty() here. Check the PHP manual for the differences or ask ^^).

minitauros 151 Junior Poster Featured Poster

This should work:

$('form#your_form').submit(function() {

    // Your code here.


    // Return false so that the form will not actually be submitted.
    return false;
});
minitauros 151 Junior Poster Featured Poster

That is because your "mouseout" event is bound as soon as the user mouseovers your image. So if a user mouses over the image 100 times, the "mouseout" event will be bound 100 times. If you follow the example I provided, your problem should be fixed :).

minitauros 151 Junior Poster Featured Poster

Well, if you bind an event inside another event, i.e. binding the mouseout event as soon as the user mouseins, it means that the event will be bound every time the user mouseins.

That means that you in your current situation, you are actually saying:

When the user's mouse hits the image, bind the event "mouseout" to the image. And when the user's mouse hits the image again, the same event is bound to it again and again and again. Not sure if it is bound until infinity, but that seems to be where the problem lies in your case (please do correct me if I'm wrong, cause while writing this I'm becoming a bit unsure about if this is really the problem).

What you should do is move the mouseout event to outside the mousein event.

E.g.:

var img=document.getElementById('newImg');

img.addEventListener('mouseover',function(e){
    e.target.width+=200;
    console.log(e.target.width);
},false);

img.addEventListener('mouseout',function(e){
    e.target.width-=200;
    console.log(e.target.width);
},false);

I think that should fix it.

minitauros 151 Junior Poster Featured Poster

God damnit I was just getting used to Windows 8, and now they're going to bake scrambled eggs with it to make yet another new interface and who knows what. I actually kinda like Windows 8.

minitauros 151 Junior Poster Featured Poster

Doesn't the Javascript version require two http requests to be made (the post request and then the reload) versus only one when submitting a form right away?

cereal commented: also +13
minitauros 151 Junior Poster Featured Poster

Well that probably means that you have somehow specified the wrong MySQL connect/login data.

EDIT: Ahum, reading the error again, I think there might be something else wrong :p. Although I am not sure what it could be, I still suggest you validate that your connect/login data is correct.

minitauros 151 Junior Poster Featured Poster

You have bound the checkForm() function to the form's submit button. I think that's what destroying your plans here. You should probably bind the function to the submit event of the form instead of to the submit button.

minitauros 151 Junior Poster Featured Poster

Why do you have your mouseout event listener inside the other event listenere in the first place? :p

minitauros 151 Junior Poster Featured Poster

Well that means that something must be wrong with your form and/or PHP. Did you already try to find out what's in your $_POST var after having submitted the form? Because (obviously) the form must have been submitted in order for the PHP to be triggered.

Replace that echo '<p>Error: no post data was submitted.</p>'; line by:

echo '<p>Error: no post data was submitted.</p>';
echo '<pre><strong>$_POST:</strong>';
var_dump($_POST);

to see what's in $_POST.

minitauros 151 Junior Poster Featured Poster

That looks like text highlight --> add comment?

minitauros 151 Junior Poster Featured Poster

Well, maybe you should change it to this:

<html>
    <fieldset style=text-align:left>
        <form name="empdetails" id="empdetails" action="view.php">
            ID : <input type="text" id="id" name="id" ><br>
            <input type="submit" id="submit" name="view" value="view" ><br>
        </form>
    </body>
</html>

<?php
// Let's also turn off reporting notices.
error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE);

if($_POST) {
    $connect = mysql_connect("localhost","root","") or die(mysql_error());
    $db_select = mysql_select_db("employee",$connect) or die(mysql_error());

    echo '<pre><strong>$_POST:</strong>';
    print_r($_POST);
    echo '</pre>';

    // You currently use isset() to set $id. isset() is a function that returns either true or false; not the actual value.
    // To retrieve the value, you should omit isset(). Your line would become the following:
    $id = $_POST['id'];
    echo '<p>$id is now: ' . $id . '</p>';

    // We should only execute the query if an id is actually given. Here, the isset() function may come in handy.
    // We will also use the empty() function here, so that we do not only check if $id is set, but also if it has an actual readable value (in this case).
    if(isset($id) && !empty($id)) {
        $qry = "select * from emp where id='$id'";
        $result = mysql_query($qry) or die(mysql_error());

        while($row=mysql_fetch_array($result))
        {
            echo "<div> ID ".$row['id'];
            echo "<div> NAME" .$row['name'];
            echo "<div>GENDER ".$row['gender'];
            echo "<div> MOBILE" .$row['mobile'];
            echo "<div>MAIL".$row['email'];
        }
    }
    else {
        echo '<p>Error: ID was nog given.</p>';
    }
}
else {
    echo '<p>Error: no post data was submitted.</p>';
}
?>

isset() is used to check if a variable has been defined, while empty() checks if a value actually contains content.

Example:

<?php
$var = '';

var_dump(isset($var)); // …
minitauros 151 Junior Poster Featured Poster

Well, have you checked the value of $id after the form has been submitted and if a record with that $id actually exists?

Checking your code, I notice that you use isset() where you shouldn't actually use it. I have made a couple of changes in your code. Hopefully you'll understand!

<html>
<fieldset style=text-align:left>
<form name="empdetails" id="empdetails" action="view.php">
ID : <input type="text" id="id" name="id" ><br>
<input type="submit" id="submit" name="view" value="view" ><br>
</form>
</body>
</html>
my php file :
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$connect = mysql_connect("localhost","root","") or die(mysql_error());
$db_select = mysql_select_db("employee",$connect) or die(mysql_error());

// You currently use isset() to set $id. isset() is a function that returns either true or false; not the actual value.
// To retrieve the value, you should omit isset(). Your line would become the following:
$id = $_POST['id'];

echo '<p>$id is now: ' . $id . '</p>';

// We should only execute the query if an id is actually given. Here, the isset() function may come in handy.
// We will also use the empty() function here, so that we do not only check if $id is set, but also if it has an actual readable value (in this case).
if(isset($id) && !empty($id)) {
    $qry = "select * from emp where id='$id'";
    $result = mysql_query($qry) or die(mysql_error());

    while($row=mysql_fetch_array($result))
    {
        echo "<div> ID ".$row['id'];
        echo "<div> NAME" .$row['name'];
        echo "<div>GENDER ".$row['gender'];
        echo "<div> MOBILE" .$row['mobile'];
        echo "<div>MAIL".$row['email'];
    }
}
else {
    echo '<p>Error: ID was nog given.</p>';
}
?>
minitauros 151 Junior Poster Featured Poster

What does the error message say? The value you filled in for "url" seems a bit odd to me - maybe that's a file that cannot be loaded?

minitauros 151 Junior Poster Featured Poster

So what seems to be the problem? :) Do you get any errors?

minitauros 151 Junior Poster Featured Poster

I have heard of AngularJS, but I've never really looked into it. Does seem interesting, thanks for the tip!

minitauros 151 Junior Poster Featured Poster

I think you may want to style the <td> borders instead of the <table> borders to get what you're looking for. So:

table#adminTable
td {
    border: 1px solid #e2e0e0;
}
minitauros 151 Junior Poster Featured Poster

You should not use that exact example, but modify it to your own needs. Or did you do that already and is it still not working?

minitauros 151 Junior Poster Featured Poster

Well, the .htaccess that I use is usually something like:

RewriteEngine on

Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

This redirects everything to index.php. You can then use PHP to read the query string ($_SERVER['REQUEST_URI'] and other $_SERVER vars) and include the appropriate files. This .htaccess setup works like a charm for me.

I think for your specific case something like RewriteRule media\?.* media.php?$1 should also do the trick. But then again, the last time I wrote a .htaccess file is years ago so I cannot be so sure :p.

minitauros 151 Junior Poster Featured Poster

Yeah, I thought so.. Too bad, I think I'm just gonna stick with what I have for now, then. I had hoped for a way to let RequireJS "require" a .php file, which would actually be Javascript but with some PHP in it. Thanks for your answer!

minitauros 151 Junior Poster Featured Poster

Well have you read any .htaccess tutorials yet?

minitauros 151 Junior Poster Featured Poster

Why don't you just select the product merely by the product code? Or isn't that unique?

E.g.

foreach($_SESSION['products'] as $key => $cart_item) {
    if($product_code == $_GET['product_code']) {
        //* This is the product of which we're reducing the quantity.

        // Substract one (or whatever you want) from the quantity.
        $cart_item['quantity'] -= 1;

        // Save the product in its session variable.
        $_SESSION['products'][$key] = $cart_item;
    }
}
minitauros 151 Junior Poster Featured Poster

So I've given RequireJS a try this weekend, and although it appears to work pretty smooth, I can't figure out one thing: How do I combine PHP and Javascript while using RequireJS?

See, RequireJS can only work with .js files, meaning that it cannot "require" .php files. In many files, however, I use PHP to retrieve database data which is then used by Javascript. It feels pretty inefficient to me to take apart these processes and let my Javascript execute an AJAX request to retrieve the settings I can normally set with PHP directly. Is there anyone with experience with this that maybe knows a solution or a way how to deal with this?

minitauros 151 Junior Poster Featured Poster

She does indeed like to hike, and so do I, but I'm only going there for a weekend and I'd like to spend some .. quiet time with her. Activities like hiking we can always do later :).

Thanks Dani!

minitauros 151 Junior Poster Featured Poster

I'll be visiting my girlfriend who's staying in Helsinki, Finland until the end of december, and I'd like to surprise her by taking her on some kind of trip or event or something. However, last time I was there we have already seen the most popular places in Helsinki. So I was wondering, is there anyone here from Finland (or not from Finland) who knows some cool things to do in/around Helsinki? I've been thinking about renting a small cabin, but I'd actually like to get some more inspiration if I can :).

minitauros 151 Junior Poster Featured Poster

Solved it, I got kinda lost in the bunch of triggers I was creating, and apparently in all the confusion I accidentally changed a trigger to BEFORE delete instead of AFTER delete. My bad!

minitauros 151 Junior Poster Featured Poster

For some reason my triggers are recursing, while I think they shouldn't. I'll simplify the examples for the sake of you not having to read through all the code.

Trigger 1:

CREATE TRIGGER table_1_after_delete AFTER DELETE ON table_1
FOR EACH ROW
    BEGIN
        DELETE FROM table2
        WHERE table2.table_1_key = OLD.table_1_key;
    END
    $$

Trigger 2:

CREATE TRIGGER table_2_after_delete AFTER DELETE ON table_2
FOR EACH ROW
    BEGIN
        -- Only execute the UPDATE query if a record still exists in table_1, from which we have
        -- deleted a record, triggering this function and targeting back table_1 (recursion).
                CASE
                    WHEN 
                        (SELECT table_1.table_1_key
                        FROM table_1
                        WHERE table_1.table_1_key = OLD.table_1_key)
                        IS NOT NULL
                    THEN
                        UPDATE table_1
                        SET table_1.var1 = NULL,
                            table_1.var2 = NULL
                        WHERE table_1.table_1_key = OLD.table_1_key;
                    ELSE
                        BEGIN
                        END;
                END CASE;
    END;

The problem is: I think that trigger 2 should recognize that the record from table_1 has been deleted, preventing the UPDATE query from being executed. However, it does not recognize this; the UPDATE query IS still being executed, and an error is being thrown: *Can't update table 'table_1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. *

Does anyone know if this is some kind of MySQL restriction? Or might it be expected/intended behaviour? Any workarounds for this?

minitauros 151 Junior Poster Featured Poster

Just for your information: you can also use PHP to read your URL. Say your .htaccess is like this:

RewriteEngine on

Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

Everything is redirected to index.php. In index.php, you can use $_SERVER['REQUEST_URI'], for example, to parse the URL and load the file you wish to load.

minitauros 151 Junior Poster Featured Poster

I don't think I fully understand your question. Could you give us some more background info? Like the table structure and the queries you are using? :)

minitauros 151 Junior Poster Featured Poster

What is the query that you are using to delete the record? Are you not in a transaction that is cancelled and rolled back? Some background info (queries) would not be misplaced here :).

minitauros 151 Junior Poster Featured Poster

Well, let's say you have this setup:

<input type="checkbox" name="a_checkbox0" value="a_value0">
<input type="checkbox" name="a_checkbox1" value="a_value1">
<input type="checkbox" name="a_checkbox2" value="a_value2">
<input type="checkbox" name="a_checkbox3" value="a_value3">
<input type="checkbox" name="a_checkbox4" value="a_value4">
<textarea name="a_textarea"></textarea>

Then on your PHP page, you could easily access the value of the textarea (once the form is submitted), and use that value instead of the value of your checkbox? Like:

<?php
$last_checkbox_value = $_POST['a_checkbox4'];
$textbox_value = $_POST['a_textarea'];

// Use $textbox_value instead of $last_checkbox_value if you want that value.
// ..

Or do you want the checkbox to obtain the value of the textarea BEFORE the form is submitted?

minitauros 151 Junior Poster Featured Poster

You will need to put that file name inside an <img> tag, I guess ;). And I also think you probably should've posted that question in a new topic, but that's too late now, anyway, I guess.

minitauros 151 Junior Poster Featured Poster
minitauros 151 Junior Poster Featured Poster

Your script should include something like this:

var number_of_timeouts_executed = 0;

// (Your decrement function:)
function decrement() {

    // If 10 or more timeouts have already been excuted, it's been 10 seconds or more. 
    // Don't execute this function again.
    if(number_of_timeouts_executed >= 10)
        return false;

    number_of_timeouts_executed++;

    // (Your timeout:)
    setTimeout();
}
minitauros 151 Junior Poster Featured Poster

So there's a textarea on page A, and a checkbox on page B, and a value from page A needs to be passed on to page B and given to a checkbox?

minitauros 151 Junior Poster Featured Poster

You could add a counter that counts how many times the function has been executed. If it reaches 10, you could prevent the timeout from being set again. I hope that's clear enough :).

minitauros 151 Junior Poster Featured Poster

I'm sorry but I find it kind of hard to understand your question :p. Is what you're asking: 'How do I pass the value of a textarea to a checkbox WHILE staying on the same page?' If yes, I'd say you'd have to use Javascript for that. If not, could you maybe rephrase your question?

minitauros 151 Junior Poster Featured Poster

If you're paying for hosting and if you don't have access to your own MySQL config files, I think you should contact your hosting company and ask them for help. Most solutions that I find on Google (just copy/paste your error into the Google search bar and you'll find plenty) talk about modifying config files.

minitauros 151 Junior Poster Featured Poster

I'm not sure, but most posts I've read about this notice that using the format() function might work. So you would return a value that is returned by Datetime::format() instead of just Datetime.

minitauros 151 Junior Poster Featured Poster

Well that's pretty weird :p. The statement should then also be triggered with || if you ask me.

minitauros 151 Junior Poster Featured Poster

Does either of those statements return true or 1 or anything that is not null or false? If yes, then your || operator is working for sure :).

minitauros 151 Junior Poster Featured Poster

Upon registration, you save the salt that was used to encrypt the password, and you retrieve it upon login to encrypt the password again with that same salt. At least, that is for as far as I know it works.

minitauros 151 Junior Poster Featured Poster

Yes it could. If you encrypt the same password using different salts, you will get different results, and thus the passwords won't match - ever.

Example:
Upon registration you use the salt "asdfjasdfp1231" to encrypt "MyPassword123". Upon logging in you use salt "@!$)@Y#$!H)@H" to encrypt that same "MyPassword123". Now, the passwords entered by the user might be the same; the encrypted passwords will differ, because you have used different salts.

(Not sure if this is what you mean, but I sure hope it is.)

minitauros 151 Junior Poster Featured Poster

You need to re-assign the onclick functionality after you clone the content, because the cloned content doesn't have any onclick functionality yet. So I guess you need to execute this code again after you clone the content:

 $('.CityTable thead').click(
    function() {
        $(this) .parents('.CityTable').children('tbody').toggle();
    }
)
minitauros 151 Junior Poster Featured Poster

Well then can't really think of another way to find out what's going wrong :. What I would do is:

  1. Check until where the script runs (is the while() loop reached, is the required if() loop reached?).
  2. Depending on where the script is halted, check what is causing the halt/discontinuation.
  3. In your case that seems to be a faulty password match. This means that we must validate that the password that is given through the form, encrypted, SHOULD match the password in the database, and if it doesn't, why it doesn't. I would try something like:

(register.php)

$password = $_POST['password'];

echo '<pre>$password is now: ' . htmlentities($password) . '</pre>';

// Encrypt your password here.

echo '<pre>$encrypted_password is now: ' . htmlentities($encrypted_password) . '</pre>';

(the same goes for your login.php page)

$password = $_POST['password'];

echo '<pre>$password is now: ' . htmlentities($password) . '</pre>';

// Encrypt your password here.

echo '<pre>$encrypted_password is now: ' . htmlentities($encrypted_password) . '</pre>';

If both the submitted password and the encrypted password are exactly the same on both pages, the problem apparently lies not in your encryption process, but somewhere else.

Also, the error you should be getting right now is the Invalid password Press back and try again<br /> error. Is that the one you're getting?

minitauros 151 Junior Poster Featured Poster

Yes :). It's because when the document is ready, a function checks for the existence of .CityTable thead elements and enables toggle functionality for them. If you clone the element, however, a new element is added to the page, without the toggle functionality. If you re-execute the stuff that is in your $(document).ready() function, it should work.