You can not show text before PHP is executed, however you can show a message after the PHP is executed and the HTML is being loaded by the browser:
http://www.weberdev.com/get_example-4431.html
~G
You can not show text before PHP is executed, however you can show a message after the PHP is executed and the HTML is being loaded by the browser:
http://www.weberdev.com/get_example-4431.html
~G
Line 9 -> You put quotes around the column name, also it is a bit vague what you mean with $_REQUEST , why are you using the same value as column name?
The select query is formatted as following:
SELECT * FROM table WHERE column='value'
Echo your query and check whether it is correct, for example by copying it and then paste it into PHPMyAdmin and then execute it to see what is wrong.
~G
The solution is pretty simple, I think?
It does not matter what choice you make:
Option A) If you shoot him, you will die anyway (because of old age) and your family will also die eventually (because of old age)
Option B) If you decide to not shoot him, you will die immediatly/soon due to starvation assuming you can not find any food or return home, and your family will also die eventually (because of old age)
Conclusion: Shoot the rabbit and eat it (Option A)
The book sounds like it has some good information on how to create web applications on the large-scale, but why is there a dog on the cover? Just wondering...;)
Right... Not any of the people that help here have experience with PHP NUKE (that I know of), and even if they did, they would never go through 500 lines of code, of which they do not know what code does what. Perhaps you should narrow your problem down to a max of 50 lines and post a reply containing it?
You can just simply do the following if you want 1 field to be required:
if (isset($_POST['field'])) {
$field = htmlentities(addslashes($_POST['field']));
} else {
$field = "";
}
if ($field != "") {
// Do something
echo "Good you entered something at 'field'!";
} else {
echo "The field 'field' is required!";
// Do some other stuff
}
~G
There are a few points you need to adjust in your HTML
>> You should stop using spaces between attributes and their values
>> The input tag needs to be self-closed
Correct usage example: <input type="radio" name="course" value="CBA" />
And then there are a few points you need to improve in your PHP code:
>> Line 5 - You are not yet certain that the variable 'flag' is set, so you should use the following:
if (isset($_GET['flag'])) {
$flag = htmlentities(addslashes($_GET['flag'])); // Removing all bad things like HTML and quotes
} else {
// Default value:
$flag = -1;
}
>> Line 9-15 and 33-39 - You need to clean the retrieved data before executing it, as people can mess up you query by using quotes:
$variable = htmlentities(addslashes($_POST['variable']));
You can find other tips for programming here: http://www.webdevproject.com/guides/programming/guide2.html
You also did not tell us what went wrong with your code, because at first glance, it looks alright and it is practically well written.
~G
Right... Line 12 + 17 - variable 'submit' undeclared. You should use the following:
function showHide()
{
if(document.getElementById('Checkbox1').checked == true) // If the checkbox is already checked
{
document.getElementById('submit').disabled = true;
}
else // If the checkbox is not yet checked
{
document.getElementById('submit').disabled = false;
}
}
And in your form:
<input id="Checkbox1" onclick="showHide(); return true;" type="checkbox" />
If this does not work, perhaps you should alert() the variables you retrieve out of the HTML using getElementById()...
~G
Which he is not on line 11 + 12
But yes you are right, you can code in one line:
if (x == 0) { x++ }
But doens't this look nicer :)
if (x == 0) { x++; }
~G
1. You neglected to end each line with a ;
2. It is window.location.href = 'URL';
3. Your indenting is a bit weird, see the following URL on how to code properly: http://www.webdevproject.com/guides/programming/guide2.html
~G
If you want to shorten a URL, you either use only a .htaccess file or a combination of a .htaccess file and a PHP script.
The basic principle:
- Either admins or visitors (I don't know why you need to shorten URL's, perhaps as service or for usage on your own site) can enter a URL in some kind of form,
- When the form is submitted:
first it is checked whether the URL already exists, if so display the already generated short URL (e.g. tinyurl.com/1c2).
If the URL does not yet exist in the database, insert the URL into the database, then retrieve the last database entry's ID (this is either in hexadecimal or decimal) and then show the created URL to the user.
- Your .htaccess file should be something like this:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([A-Za-z0-9]+) /redirect.php?turl=$1 [NC]
- And then you have redirect.php that retrieves the turl from the database, and then directs the user to the original URL (with the Header() function for example)
If you do not have the programming experience to do the above, either hire someone or find a shorten url script somewhere (although they do not grow on trees)
See the following link:
http://www.google.nl/search?q=shorten+url+script
~G
You mean blur = make more light?
See the following link: http://www.w3schools.com/Css/css_image_transparency.asp
~G
It is positioned fixed:
<div style='position:fixed; bottom:0px; left:0px; height:20px; width:100%; background-color:blue; z-index:100000000000;'>
This is a bar on the bottom
</div>
However, this only works in FF. As you can see at DaniWeb, the toolbar only pops up in FF and not in IE.
~G
Line 13 - Undeclared variable xmlhttp. Before you create the object, user
var xmlhttp = false;
Then before you do the request, use:
if (xmlhttp) {
//... Your code....
} else {
alert('Could not create AJAX object.');
}
If this does not solve it, you should add alert()'s between your code to debug your code. Here you can find other tips: http://www.webdevproject.com/guides/programming/guide1.html
~G
Look, I was willing to correct your code and remove the syntax errors. Apply my code, and work the PHP out yourself. The JavaScript timer should work. Also check the HTML source code for wrong output.
~G
As this is urgent, iil give you the solution, but study the code and learn from your mistakes. Each code lines needs to end with a ;, use more spaces and pay attention on how I use the setTimeout() function:
setTimeout(function(){
//Here should be all the code you want executed
}, 0);
And here how it is implemented:
<script type='text/javascript'>
<!--
var milisec=0;
var seconds=<?php echo $s;?>;
// I directed this (document.counter.d2.value='0';) to setTimeout, as the document has not yet been loaded
function display(){
if (milisec <= 0){
milisec = 9;
seconds -= 1;
}
if (seconds <= -1){
milisec = 0;
seconds += 1;
} else {
milisec-=1;
document.counter.d2.value=seconds;
setTimeout(function(){ display(); },100);
}
}
window.onload=function() {
document.counter.d2.value='0';
display();
}
-->
</script>
~G
You forgot to add the unit to the value and your CSS is not entirely correct, use the following:
#cart {
overflow:auto;
border:1px solid red;
height:500px;
margin-left:10px;
margin-right:10px;
margin-top:20px;
margin-bottom:0px;
font-size: 12px;
text-align: left;
font-family: Verdana, Geneva, sans-serif;
background-image:url('images/side.gif');
background-repeat:no-repeat;
}
~G
That is indeed easy to do:
<select onchange='clearFields()'>
.... Some other html etc....
<input type='text' id='InputId' maxlength='255' />
And then the javascript:
function clearFields() {
document.getElementById('InputId').value = "";
}
~G
I told you how to change the code so that it does work, and you can do that yourself. Use alert()'s between to see where the code fails. Try some things yourself, and if you can't figure it out, post your new code and I'il guide you further.
~G
You should check out one of the problems I solved, concerning AJAX. Take a look at the function and implement it into your code (change some variables such as the url etc...)
http://www.daniweb.com/forums/thread303429.html
~G
Right... Well you need to isolate the search code out of the php and put in in search_engine.php . search_engine.php retrieves the variables out of the URL using GET and searches your database. Then it echoes all the rows found.
Then you create a JavaScript function that retrieves the value out of the textbox that contains the search-words, and add that to the url (e.g. search_engine.php?q=my+search+words . Then use AJAX to call the page (using the URL you formatted) and then when the states are correct, use a document.getElementById('yourdivid').innerHTML = ajax.responseText;
to show the results.
~G
>> Line 21 - The variable "i" is only available in the for loop, and so on line 27 "i" is not declared.
>> Line 26 - GlobalPic not declared. Move var globalPic to line 1 from line 42.
>> Use alert() between the code to debug your code.
~G
The correct syntax to hide something is the following:
document.getElementById('theId').style.display='none';
document.getElementById('theId').style.display='inline';
~G
Right... dirty is not a property of any type of HTML, except if someone made his own using XML. However, your code should be the foolowing:
<div class="Block FeaturedProducts Moveable Panel" id="HomeFeaturedProducts" style="display:%%GLOBAL_HideHomeFeaturedProductsPanel%%">
<h2>%%SNIPPET_HomeFeaturedProductsFeed%%%%LNG_FeaturedProducts%%</h2>
<div class="BlockContent">
<script type="text/javascript">
// SPECIFY THE NAME OF BANNER HERE
// REMEMBER THAT NAME OF VARIABLE AND ARGUMENT PASSED SHOULD BE SAME
// HERE IT IS 'banner1'
var banner1 = new Banner('banner1');
// IF YOU WANT THE BANNER TO CHANGE ON PAGE REFRESH
// THEN SET THE FOLLOWING VALUE TO true (DEFAULT VALUE IS false)
banner1.changeOnRefresh = false;
// ADD THE BANNER HERE
// FIRST ARGUMENT : "FLASH" OR "IMAGE"
// SECONG ARGUMENT: PATH OF THE FILE
// THIRD ARGUMENT : DURATION IN SECONDS
// FOURTH ARGUMENT : HEIGHT
// FIFTH ARGUMENT : WIDTH
// SIXTH ARGUMENT: HYPERLINK
// SEVENTH ARGUMENT: TARGET
banner1.add("IMAGE", "http://orbiselectronics.mybigcommerce.com/content/bannerimages/1.jpg", 3, 210, 600,"http://net-impulse.com", "_blank");
banner1.add("IMAGE", "http://orbiselectronics.mybigcommerce.com/content/bannerimages/2.jpg", 3, 210, 600,"http://net-impulse.com", "_blank");
banner1.add("IMAGE", "http://orbiselectronics.mybigcommerce.com/content/bannerimages/3.jpg", 3, 210, 600,"http://net-impulse.com", "_blank");
// START THE BANNER
document.write(banner1);
banner1.start();
</script>
</div>
If the HTML you were given by the writer of this script is as good as his JavaScript writing skills, this might not even work.
~G
That really is not that difficult. You can change the display of a element using:
document.getElementById('divId').style.display='none';
document.getElementById('divId2').style.display='inline';
And the 2nd line javascript should be triggered onmouseover, and the 1st line onmouseout. Make them into 2 little functions and voila you got yourself a popup.
~G
That is some real strange quote work you got there. Perhaps if you would clean up your quotes it might help...
Example of a correct usage of quotes (the code has nothing to do with yours, just watch how the quotes are placed):
<div class="someClass">
<hr class="main_sep" />
<img src="images/img001.png" border="0" />
<hr class="main_sep" />
</div>
~G
If you want the page to not reload, JavaScript is the way to go. However as you do not have experience in programming with JavaScript and the subset of JavaScript functions AJAX, I recommend you use only PHP.
When you only use PHP you need to do the following:
if (isset($_POST['set_grade_subm'])) {
// Process the set-grade form
} else {
if (isset($_POST['student_id'])) {
// Show the form which allows you to change the grade
} else {
// Retrieve all students from the database and all give them a checkbox with the value of their ID
// Put those in a form with a submit button below it
}
}
The form needs to have the following fields (their names):
- student_id, containing the student id (hidden input)
- new_grade, containing the student grade (textbox)
- set_grade_subm, submit button
If you do not have alot of PHP-experience I would suggest you read through some guides online (http://tizag.com/ , http://www.w3schools.com ) or read a book about PHP & MySQL (for example PHP & MySQL for Dummies, and if you are a bit further than that PHP Advanced: Quickpro guide by Larry Ullman).
~G
Right... Your extensive code really gives the impression you worked very hard on it... You should check out some tutorials on AJAX:
http://www.google.com/search?q=ajax+tutorial
The top 5 explain everything.
~G
Well, that is alot more difficult. Anyway here how it is done:
<form name='MyForm' onsubmit='checkValue();' action=''>
And then in the JavaScript:
var form_allowed_to_submit = false; // This is a global variable
function checkValue() {
if (form_allowed_to_submit == false) {
prompt2('Confirm','Do you realy want to submit form?', 'yes()','no()','Yes','No');
}
return form_allowed to_submit;
}
And then in your yes() function:
form_allowed_to_submit = true;
document.MyForm.submit();
I hope you set the variable $id in code you have not shown yet, and cleaned that with htmlentities() and addslashes(). If you are counting on register_global of PHP, you are creating a huge security leak. Well anyway, to solve your problem, you first need to select the row, check whether there is a row with that id (num_rows > 0) and then delete it:
$q1 = "SELECT * FROM databasemanager WHERE id='".$id."' LIMIT 1";
$r1 = mysql_query($q1) or die("Could not retrieve row. 1");
if (mysql_num_rows($r1) > 0) { // If the id exists
$q2 = "DELETE FROM databasemanager WHERE id='".$id."' LIMIT 1 ";
$r2 = mysql_query($q2) or die("Could not delete row. 2");
// The rest of your code...
}
~G
You got to be kidding me, these type of effects are not possible in JavaScript. I know jQuery has alot of reasonably good functions, but no where near that. If I am wrong, correct me and send me a link to where I am proven wrong.
~G
You can easily ask the user whether he wants to submit the form or not:
<form method='post' action='' onsubmit='return confirm("Are you sure you want to submit this form?");'>
The confirm() returns true if the user selected "yes" and false if the user selected "no".
~G
You need the second one, the href isn't going to work. However when a <a> element is clicked the page is reloaded. But not if you do it like the following example:
<div id="ajaxlink"><a onclick="loadurl('ajax_function.php'); return false;">Click Here</a></div>
~G
Well the AJAX is completely wrong ;) , let me explain how AJAX works:
- You create a XMLHTTP request object
- You define a function that is triggered when the readystate is changed of the XMLHTTP object
- You open a url using the XMLHTTP object
- You send some data via the XMLHTTP object
- Everytime the readystate and status change, the function you defined at step 2 is called
Here is an example of an AJAX function (that loads the url):
function loadurl(url) {
var ajax = false;
// Create the object:
// Choose the objecttype, depending on what is supported:
if (window.XMLHttpRequest) {
// IE 7, Mozilla, Safari, Firefox, Opera, most browsers:
ajax = new XMLHttpRequest();
} else if (window.ActiveXObject) { // Old IE-browsers
// Make the type Msxml2.XMLHTTP, if possible:
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) { // Else use the other type:
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) { }
}
}
// Retrieving the data from the page
if (ajax) {
alert("url: " + url);
ajax.open('GET', url);
// Sends request
ajax.send(null);
// Function that handles response
ajax.onreadystatechange=function(){
// If everything is OK:
if ( (ajax.readyState == 4) && (ajax.status == 200) ) {
// Returns the value to the document
alert(ajax.responseText);
}
}
} else { // AJAX is not useable
alert('It is not possible to connect, please update your browser.');
}
}
~G
At first view, the code looks alright. You should place alerts everywhere in your javascript code. Also I would recommend you use the GET method, as POST method is a bit more difficult. So try out this function:
function predeployment(id) {
var ajax = false;
// Create the object:
// Choose the objecttype, depending on what is supported:
if (window.XMLHttpRequest) {
// IE 7, Mozilla, Safari, Firefox, Opera, most browsers:
ajax = new XMLHttpRequest();
} else if (window.ActiveXObject) { // Old IE-browsers
// Make the type Msxml2.XMLHTTP, if possible:
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) { // Else use the other type:
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) { }
}
}
// Retrieving the data from the page
if (ajax) {
var url = "predeploymentdata.php?id=" + encodeURIComponent(id);
alert("url: " + url);
ajax.open('GET', url);
// Sends request
ajax.send(null);
// Function that handles response
ajax.onreadystatechange=function(){
// If everything is OK:
if ( (ajax.readyState == 4) && (ajax.status == 200) ) {
// Returns the value to the document
alert(ajax.responseText);
}
}
} else { // AJAX is not useable
alert('It is not possible to connect, please update your browser.');
}
}
~G
Try googling? There are plenty of links out there (with explaination)...
http://www.leigeber.com/2008/04/sliding-javascript-dropdown-menu/
~G
Perhaps you should use properly write your programs, instead of scrambling it up, putting everything right next to eachother? Use more enters to seperate each line.
No one will voluntairly read through someone else's code which is poorly written and try to figure out what the hell he is trying to accomplish with it. If you could isolate the problem and post small pieces of it which causes the problem, then perhaps we would.
~G
You know, Googling isn't that difficult, 2/5 top five give a solution:
http://www.webdesignforums.net/javascript_ajax_json_6/javascript_command_print_image_30898.html
http://www.webdeveloper.com/forum/showthread.php?t=178631
~G
You can not open a .js file in your browser. You need to link it to a HTML file by using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My first page with JavaScript</title>
<script type='text/javascript' src='scripts/MyScript.js'></script>
</head>
<body>
</body>
</html>
Or write the code into the HTML file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My first page with JavaScript</title>
<script type='text/javascript'>
alert("This is some JavaScript code!");
</script>
</head>
<body>
</body>
</html>
~G
Your code should be the following, also check out macgurl70's link.
<script type="text/javascript">
if (navigator.appName == 'Microsoft Internet Explorer') {
// Only for IE (that poorly made and pathetic little browser):
var counter = 0;
window.onresize = function (){
if (counter == 1) {
ChangeSize();
counter--;
} else {
counter++;
}
}
} else {
// For all other (major) browsers:
window.onresize = function (){
ChangeSize();
}
}
function ChangeSize() {
var width = 0, height = 0;
if (navigator.appName != 'Microsoft Internet Explorer') {
width = parseInt(window.innerWidth);
height = parseInt(window.innerHeight);
} else {
width = parseInt(document.body.clientWidth);
height = parseInt(document.body.clientHeight);
}
if ((width < 640 && height < 480)) {
window.resizeTo (640,480)
} else {
window.resizeTo (width, height)
}
}
</script>
Although this code does what you want, when you maximize/minimize the window, it gets messed up. Also it is extremely annoying even if you don't. I recommend you do not use this code because of that.
~G
I need to create a row and its content to be unchangeable and undeleteable, as a secure way to ensure that the administrator will always have access to the website. Does anyone have any idea how to do this? A Google Search gave no results, but perhaps someone knows how to do this. Please post your suggestions below.
~G
Well, you can make it browser specific:
<script type="text/javascript">
if (navigator.appName == 'Microsoft Internet Explorer') {
// Only for IE (that poorly made and pathetic little browser):
var counter = 0;
window.onresize = function (){
if (counter == 1) {
alert("Thanks for resizing!");
counter--;
} else {
counter++;
}
}
} else {
// For all other (major) browsers:
window.onresize = function (){
alert("Thanks for resizing!");
}
}
</script>
~G
Although I do not have any experience with Rotating ad banners, I do see the cause of your problem:
>> Line 6, 7, 8 - It is a mix of various quotes and they are aligned wrong. Use the following:
textads[0] = "<a href=\"http://www.leighfibers.com\" target=\"_blank\" onClick=\"javascript: _gaq.push(['_trackPageview', '/bannerad/leighfibers']);\" ><img src=\"http://www.sleepproducts.org/ISPANEW/images/bannerads/August_LeighFibers.jpg\" border=\"0\"></a>";
textads[1] = "<a href=\"http://www.henkelna.com/foambonding2\" target=\"_blank\" onClick=\"javascript: _gaq.push(['_trackPageview', '/bannerad/henkel']);\" ><img src=\"http://www.sleepproducts.org/ISPANEW/images/bannerads/July_Henkel.jpg\" border=\"0\"></a>";
textads[2] = "<a href=\"http://www.storksmt.com/Stork/6212/Bedding_Evaluation.html\" target=\"_blank\" onClick=\"javascript: _gaq.push(['_trackPageview', '/bannerad/stork']);\" ><img src=\"http://www.sleepproducts.org/ISPANEW/images/bannerads/August_Stork.gif\" border=\"0\"></a>";
~G
I don't know how the update() function is formatted. Post your code else I can't help.
~G
Thats fairly easy:
<script type='text/javascript'>window.onload=function(){ update(document.getElementById('qty')); }</script>
You should place this beneath the form HTML, so that the id already exists.
~G
it needs to be:
<script language="JavaScript" type="text/javascript">
function goTo() {
document.location.href="subscribeJ.asp";
}
window.onload=function(){
setTimeout(function(){ goTo(); },10000);
}
</script>
and the body should just be:
<body>
~G
line 21 - You put pans at 1 every time the loop is repeated.
~G
1) I (and I think nobody) will read through all your code
2) There is a mail() function in PHP: http://php.net/manual/en/function.mail.php
3) The mail() function only works if there is a mail system on your server/computer
4) If you still want to use the code you posted above, I would like to refer you to the reference manual or the writer of the script
~G
I assume you are making a admin area, and this is a setting that determines whether someone from any country can be accepted or from some countries not.
You retrieve the values and save them in the database:
// Retrieving the form values, and cleaning them from HTML and quotes
$accept_all_citizenship = htmlentities(mysql_real_escape_string($_POST['accept_all_citizenship']));
$ud_not_citizenship = htmlentities(mysql_real_escape_string($_POST['ud_not_citizenship']));
// Updating the table
$query = "UPDATE settings SET accept_all_citizenship='".$accept_all_citizenship."', ud_not_citizenship='".$ud_not_citizenship."'";
$result = mysql_query($query);
mysql_query($query);
And then you retrieve its value on the page which has the form for people that want to apply, and check whether the citizenship is accepted. If you do not know how to do this, I strongly recommend you to read a bit more books on MySQL and PHP.
~G