Posts

how to work ajax and php in single code

this link show what do you wanted    its' simpler and great demo http://simpletutorials.com/?path=tutorials/javascript/simple_ajax

PHP: give alert popup then redirect the page

Do something like header ( "Location: index.php?Message=" . urlencode ( $Message )); Then on index.php... if ( isset ( $_GET [ 'Message' ])) { print $_GET [ 'Message' ]; } In other words, index.php will always check if it's being passed a message in the url. If there is one, display it. Then, just pass the message in the redirect if you really want to use a modal popup, generate the js... if ( isset ( $_GET [ 'Message' ])) { print '<script type="text/javascript">alert("' . $_GET [ 'Message' ] . '");</script>' ; }

PHP: give alert popup then redirect the page

code goes this   if ( $_FILES [ 'file' ][ 'size' ] > 200000 ) //any file size, 200 kb in this case { echo "<script type='javascript'>alert('File size larger than 200 KB')</script>" ; } header ( "Location: index.php" );         The browser will be redirected to index.php page anyway, no matter the file is successfully uploaded or not. Its just that the popup will appear if the file is of larger size.

Javascript Confirm Delete in One PHP File (on href)

You can set the onclick attribute of the link. If the function returns false , the link will not proceed. <a href = "deletephone.php?id=' . $row['id'] . '" onclick = " return confirm ( 'Are you sure?' ); " > Delete Phone </a> Here, the confirm() function will return true if the user pressed OK, and false if the user pressed Cancel.

echo javascript with single quotes

You are echoing outside the body tag of your HTML. Put your echos there, and you should be fine. Also, remove the onclick="alert()" from your submit. This is the cause for your first undefined message. <? php $posted = false ; if ( $_POST ) { $posted = true ; // Database stuff here... // $result = mysql_query( ... ) $result = $_POST [ 'name' ] == "danny" ; // Dummy result } ?> <html> <head></head> <body> <? php if ( $posted ) { if ( $result ) echo "<script type='text/javascript'>alert('submitted successfully!')</script>" ; else echo "<script type='text/javascript'>alert('failed!')</script>" ; } ?> <form action = "" method = "post" > Name: <input type = "text" id = "name" name = ...

why we use this function mysql_real_escape_string()

when we are entering data in to mysql database and that contain the single quote. that time data is not entering into database and showing error then we we use this function . there are other function to remove the the to remove the quote but this one is easier one thank you

MySQL error: “Column count doesn't match value count at row 1” - beginner help

I understand that you're not providing a value since it's likely a PRIMARY KEY that autoincrements. To tell MySQL that you are intentionally not passing a value for that column, you should add NULL as the first value.