MDGM 22 Posting Whiz in Training

Hi All,

Can somebody tell me how I can remove the email addresses I naievely posted in this thread some years ago:

http://www.daniweb.com/web-development/web-design-html-and-css/threads/58133/asp-form-action-script

I can't seem to find a post edit button..

Thanks,
Max.

MDGM 22 Posting Whiz in Training

Can an admin take out all email addresses from this thread? They are getting picked up by crawlers and sold to spammers.

Either that or somebody tell me how I can do it; no edit button...

Thanks,
Max.

MDGM 22 Posting Whiz in Training

Can an admin take out all email addresses from this thread? They are getting picked up by crawlers and sold to spammers.

Either that or somebody tell me how I can do it; no edit button...

Thanks,
Max.

MDGM 22 Posting Whiz in Training

Iv had a go at that, the key I need to override is backspace but entering the backspace code (8) does not seem to work. How should that work?

MDGM 22 Posting Whiz in Training

Thanks for your reply,

The process does not involve any iFrames. I am going to use this in a browser add-on and so the javascript will be inserted directly into the page as if I was the developer of that website and just inserting code as normal.

Max

MDGM 22 Posting Whiz in Training

Hi all,

I want to know if it is possible and how to intercept an existing javascript keybind and block it.

For example, a website has some javascript that, when the user hits the letter "H" on the keyboard, the website automatically runs a function, e.g. redirecting to another web page.

I want to block this functionality after it has been loaded into the page.

Is this possible? Perhaps the stoppropagation function? Or maybe simply re-assign the key event to just run an empty function?

Thanks,
Max.

MDGM 22 Posting Whiz in Training

ahh okay, not what i would need. thanks anyway :)

MDGM 22 Posting Whiz in Training

Is there a way to, when the url changes, intercept it and take the user to a different page?

For example, if the user types in "facebook:" and then some other random words, like "facebook: eating my dinner" it takes the user to the facebook share page instead of just googling those words?

Seems unlikely for security reasons etc but im curious......

MDGM 22 Posting Whiz in Training

Ahhh of course, didnt think of that! :) I'll do that in the future. Thanks everybody for the help - it's been a while since I'v used javascript and maintained my chrome extensions :)

MDGM 22 Posting Whiz in Training

Hi,

Thanks for the reply. I know about variable scope, i just needed help getting round it.

In the end I just put the rest of my code for the page inside the same function, it required quite a lot of changes to the script but it's all I could do to work around it.

MDGM 22 Posting Whiz in Training

Hi all,

I'm making some changes to a google chrome extension I made and am having some trouble.

Heres my code on a content script page (removeAttr.js) :

chrome.extension.sendRequest({greeting: "whitelist"}, function(response) {
    var whitelist = response.whitelist;
    console.log(response.whitelist);//working
});
alert(whitelist);//alerts "undefined"

How do I acess the whitelist variable from outside the sendrequest() function?

Iv tried saving it to a window.var variable with no luck. Iv tried creating a div and assigning it's innerHTML as the whitelist variable and getting it later with no luck.

The fact that it's a chrome extension complicates things because i dont actually know if i can create elements from where the script is located.

Can anybody help me?

Max.

MDGM 22 Posting Whiz in Training

Hey, sorry for the super late reply but iv been really busy.

In the end I just started over with the articles part of the site and am now using wordpress to manage all my articles and am using it's permalink function to get search-engine-friendly urls.

here:

http://www.effectivecounselling.co.uk/articles

I made a custom theme and integrated it into my site design, was actually very easy, for anybody elses reference theres a great tutorial here:

http://codex.wordpress.org/Integrating_WordPress_with_Your_Website

Thanks for your help, i might need this later anyway :)

Max.

MDGM 22 Posting Whiz in Training

I know, the links above use the url www.example.com just for the sake of this thread.

The website currently has urls like this:

www.example.com/articles.php?aid=3

and I want to use .htaccess and apache's mod_rewrite to get information from the sites database and put that information in the url.

Let's say the article with primary key aid=3 (as shown in the url above) has the title "how to fix a laptop" in the database. I want to get that title from the database and re-write the url from what is above to the following:

www.example.com/articles/how-to-fix-a-laptop

MDGM 22 Posting Whiz in Training

Hi all,

I have a site that has a dynamically generated page and looks like this:

www.example.com/articles.php?aid=1
www.example.com/articles.php?aid=2
www.example.com/articles.php?aid=3

The page has the article title and description stored in a database and printed in the page itself.

How do I go about changing the URL from this:

www.example.com/articles.php?aid=1

To this:

www.example.com/articles/how-to-fix-a-laptop

where the article description is stored in a database?

Thanks in advance.
Max.

MDGM 22 Posting Whiz in Training

ahh great, it works now. thanks for the help

MDGM 22 Posting Whiz in Training

iv just found a function called removeattribute and am trying to figure out how to apply this to every element on the page.

So far I have this:

for(var i=0; document.all < document.all.length; i++) {
    document.all[i].removeAttribute("title");
}

but its not making any changes to the page.
Can anybody shed some light?

MDGM 22 Posting Whiz in Training

Hi all

I need a javascript code that removes all the title="*" attributes in a page, where the star (*) represents a wildcard for the content of the title attribute. So the following would occur:

<a href="#" title="test">test</a>
would be replaced with
<a href="#">test</a>

just like:

<a href="#" title="">test</a>
would be replaced with:
<a href="#">Test</a>

I know there is a function in javascript called match, but i have no idea how to write the reg expression that would work like the above example.

thanks in advance!!

MDGM 22 Posting Whiz in Training

ahhh briliant, that should work perfectly. I dont have time to test it now but when I do ill mark the thread as solved.

Thanks again!
Max.

MDGM 22 Posting Whiz in Training

Hi all,

I need a php script that gets the IP address of a user entered website, something like this:

$site = 'www.google.com';

$ip = ping($site);

obviously replacing ping with a command that actually exists!

Thanks in advance.
MAX

MDGM 22 Posting Whiz in Training

iv tried that but cant get any changes working. its quite a complex problem and I have tried many possible solutions... if anybody else has had the same thing that would be best.

I think its an encoding charset discrepency?

MDGM 22 Posting Whiz in Training

hi all,

I have a php script that saves what the user types in into a text file using fwrite, and displays it on another page using file_get_contents.

When putting in a pound sign (£), it saves the following to the text file:

£

Any idea how I can stop this from happening and instead get the pound sign working properly?

Max.

MDGM 22 Posting Whiz in Training

had some difficulty getting sqlite to work so i have decided to abandon the .db files. thanks anyway!

MDGM 22 Posting Whiz in Training

hi all,

Im desperatly looking for a .db format rhyming dictionary and have managed to get hold of three database files which I think will be VERY useful to me but I cannot open them. Can anybody help me to get them open?

I have attached the files in a .zip file to this thread.

Thanks!!

Max.

p.s. I tried importing them into a mysql database on one of my servers but it came up with a parsing error with loads of scrambled text - see below:

There is a chance that you may have found a bug in the SQL parser. Please examine your query closely, and check that the quotes are correct and not mis-matched. Other possible failure causes may be that you are uploading a file with binary outside of a quoted text area. You can also try your query on the MySQL command line interface. The MySQL server error output below, if there is any, may also help you in diagnosing the problem. If you still have problems or if the parser fails where the command line interface succeeds, please reduce your SQL query input to the single query that causes problems, and submit a bug report with the data chunk in the CUT section below:
----BEGIN CUT----
eNrsvWuMLFuW33Wm+14bN5ax/AAL2+O/he3i4LmX7q5zm+4eWTgqMyozbmVGZMeOrDpZwp7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w6/yMSYR4cqkYXfpt6EIsJjsAuSDOZYG0fCq0lVpGW2B9e7mMw1o
xfXixeNFz8+m+6tSCRWlThRCM8rYtt9MZmGim8Dp+uXj+ShfwGEMRYA+Np+4Pm/7tP6s8aT1Oc8b
2WXLaZg+MhENt5USaoUMxwry0c1DzbpfvdNhul3MwoReOcjSgFZdstuRnYQLXCNAY051DdJS25mF …
MDGM 22 Posting Whiz in Training

yeah it works great. thanks again itech

MDGM 22 Posting Whiz in Training

I didnt actually know about the .htaccess rewrite function and didnt know that this kind of setup was an option.

It's great to learn new ways of doing things through but now I have this all setup and it is working fine, I'll use this system for now, but your way will certainly be useful for future projects.

Thanks ardav and itech for your help!!

Max

MDGM 22 Posting Whiz in Training

thanks for all your help buddy! I wanted the code to replace the county/index.php pages - sorry if i wasnt clear enough. I have modified your script to change these files instead. also if anybody else uses it i have commented out the "copy" command in the "replacePage" function for testing purposes before any files are over written.

also because i cant / dont know how to run pages through command prompt or whatever i changed the argv to _GET variables so just run the page like this:

www.example.com/rpl.php?s=/www/htdocs/domain/public_html/template.php&d=/www/htdocs/domain/public_html

Thanks again!!

<?php
// Warning this may be a very bad design. Please inform nilesh [at] itech7 [dot] com if you get a better substitue.

	print "Make a backup of your files before you do modifcations\n\n";

	print "This application will overwrite any existing file without warning!\n\n";

	print "For example if your directory structure is like this -\n\n";
		
	print "\t/htdocs/domain.com/branch_finder/country/county\n\n";

	print "\tand you want to replace county/index.php with your one's\n\n";

	print "Pass argument #1 as path to source file\n\n";

	print "Pass argument #2 as the directory in which you have subdirectories as domain.com, domain.net, domain.org\n\n";

	print "NOTE: This will copy SOURCEFILE to county/index.php\n\n";

	print "By Nilesh, Site & Server Administrator of www.itech7.com\n\n<br/><br/><br/><br/><br/><br/>";



$sourcefile = '/var/www/localhost/htdocs/sharedweb/nsci/staff/cdir/template/county/index.php';

$destdir = '/var/www/localhost/htdocs/sharedweb/nsci/';

$d = new DirectoryIterator($destdir);

foreach ($d as $f) {
	
	if($f->isDir() and !$f->isDot()) { // Level 1 (domain.com's parent)
		
		$d1 = new DirectoryIterator($f->getPath() . '/' . $f);

		foreach ($d1 as $f1) {

			if($f1->isDir() and !$f1->isDot()) { // Level 2 (branch_finder's …
MDGM 22 Posting Whiz in Training

wow! thanks for all your time!!

Iv had a look at the script and it looks exactly what i needed, but im finding it a bit difficult to execute. can you give me an example of how to run it? like where should it be in the site for it to replace the right files?

also instead of executing it through the command line id like to pass the variables through the _get array

thanks again!!!

MDGM 22 Posting Whiz in Training

okay so this is the shape of the directory:

domain.com/branch_finder/country/county/branch

I have lots of pages like this so 3 examples would be:

domain.com/branch_finder/england/avon/bristol/
domain.com/branch_finder/england/dorset/poole/
domain.com/branch_finder/england/oxfordshire/banbury/

I want to overwrite each index.php page in each county (avon, dorset, orxfordshire) with a specified index.php page located on my site, using php.

MDGM 22 Posting Whiz in Training

Hi all,

I have a very large amount of files I need to update, so I thought the easiest way would be to do it with php.
Below is the current directory structure

www.domain.com/branch_finder/country/county/town/

I need to replace the existing index page in every "county" level directory inside the branch_finder folder with a page here:

www.domain.com/staff/cdir/templates/county/index.php

I am guessing I would have to run a script inside the branch_finder directory to identify each county page and replace it?

How would I go about doing this?

Thanks in advance.
Max.

MDGM 22 Posting Whiz in Training

surely just saving the login timestamp updating it every time the page is refreshed and then querying for users where the timestamp is less than x minutes ago are online would be the best answer?

MDGM 22 Posting Whiz in Training

yes post code please.

without seeing the code i think you have two options:

If you have access to the first action page (before paypal) then add this at the very end of the script (before any actual text output):

<?php
header('location: http://www.secondFormAction.com');
exit;
?>

which will forward the user to the next form action. if you do not have access to the first action then consider using ajax to submit the second action?

MDGM 22 Posting Whiz in Training

thanks for the reply and advice airshow. I had thought of having the drop down menu's automated using a database but by the time i had got to the branch page, the unique content for each page would be too detailed (with html codes and so on) to be stored in a database. Little changes will be made to the pages once they have been created anyway so I concluded it would be easiest to just do it all manually.

As for making my links search engine friendly, I will use the site map solution and consider adding text links to the pages as well underneath (also good for people with javascript turned off).

Thanks again for your help, much appreciated.

MDGM 22 Posting Whiz in Training

Hi all,

I'm creating different pages on a website for each branch in the country for a business. The way the user gets to their branch is through a dreamweaver generated jump menu.

My question is: Will search engine robots crawl the pages that are linked via the jump menu?

So for example the page for the London branch can only be navigated to via the jump menu (or typing in the url in the address bar). Will a search engine index this page?

The jump menu script is below:

<script type="text/javascript">
<!--
function MM_jumpMenuGo(objId,targ,restore){ //v9.0
  var selObj = null;  with (document) { 
  if (getElementById) selObj = getElementById(objId);
  if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0; }
}
//-->
</script>



        <form id="form">
          <select name="country" id="country" onchange="MM_jumpMenuGo('country','parent',0)">
            <option value="">Choose</option>
            <option value="">======</option>
            <option value="england">England</option>
            <option value="scotland">Scotland</option>
            <option value="wales">Wales</option>
            <option value="northernireland">Northern Ireland</option>
          </select>
          <input type="button" name="go_button" id= "go_button" value="Go" onclick="MM_jumpMenuGo('country','parent',0)" />
        </form>
MDGM 22 Posting Whiz in Training

bump

MDGM 22 Posting Whiz in Training

iv looked around quite a lot, most of them dont actually differenciate between new and default fonts. Maybe it would be good for somebody (me if i have the time to learn c+!) to design one. Id use it! :D

MDGM 22 Posting Whiz in Training

hi all,

is there a program that lists all non-default fonts that have been manually installed on your computer?

Max

MDGM 22 Posting Whiz in Training

don't worry, iv found a solution - http://clicksms.co.uk/.

You make an account, buy a minimum of 100 texts (at about 10p each - buying in bulk gets price as low as 5p i think..) and then use a simple php script to send an XML HTTP request to their servers to send the message.

only bad thing is that they don't provide a pre-made sample php script for sending the xml request but i managed to find one on a forum somewhere.

If anybody needs the script id be happy to email (or whatever..) it to them - post in this thread.
(only works with http://clicksms.co.uk/)

peter_budo commented: Thanx for sharing +22
MDGM 22 Posting Whiz in Training

(I wasn't sure where to put this thread so move it if you need to! :])

I want to be able to send a text message to my mobile phone whenever I get an email through from my website (the sending of the message would ideally be done using PHP on my sendmail.php file on the site itself).

What are my options for this considering I will probably only be getting about 1 per week?

Thanks,

Max.

MDGM 22 Posting Whiz in Training

perfect, thanks a lot :D

MDGM 22 Posting Whiz in Training

Heyy,

Thanks for the reply, your answer makes sense and seems very logical. I entered the following code in the phpmyadmin code tester:

SELECT * FROM images WHERE fbid IN (SELECT fbid FROM ratings HAVING count(fbid) > 150 GROUP BY fbid)

and got the following error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY fbid) LIMIT 0, 30' at line 1

Thanks again

MDGM 22 Posting Whiz in Training

each photo is saved in the table images with FBID as the primary key.

Then ratings are saved in the ratings table and FBID refers to the photo the rating is about.

I want to only use photos that have at least 150 ratings about them saved in the ratings table.

hope thats clearer

MDGM 22 Posting Whiz in Training

or is it not possible?

MDGM 22 Posting Whiz in Training

Sure,

$sql="INSERT INTO bookings 
(clientID, roomID, startdate, enddate, adults, children, roomtype,  requirements) 
VALUES 
('$last_insert_client_id',
'NULL',
'  str_to_date($_POST[startdate],'%d-%m-%Y')',
'  str_to_date($_POST[enddate],'%d-%m-%Y')',
'$_POST[adults]',
'$_POST[children]',
'$_POST[roomtype]', 
'$_POST[requirements]')
";

That should give you what you want.

MDGM 22 Posting Whiz in Training

I think generally to store dates into the database its best to use a timestamp. A timestamp shows the number of seconds that have passed since January 1, 1970 00:00:00 GMT. You get the current timestamp in php by using: time(); //http://uk.php.net/manual/en/function.time.php You can convert a date into a timestamp using the following: mktime('','','',$month,$day,$year); //http://uk.php.net/manual/en/function.mktime.php And you can convert timestamp into a date by using this: date('D-M-Y',$timestamp); Using these functions, get the user to enter in their date in the format you want (DD/MM/YY) using 3 different text boxes like this:

<form action="process.php" method="post">
<input type="text" name="day" value="day"/><br />
<input type="text" name="month" value="month"/><br />
<input type="text" name="year" value="year"/><br />
<input type="submit" /><br />
</form>

then on the next page process it like this:

<?php
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];

$timestamp = mktime('','','',$month,$day,$year);

//then store the timestamp into the database 
?>

Then later if you want to get the timestamp from the database do something like this:

<?php
$get_date = mysql_query('SELECT timestamp FROM table WHERE bookingID = "'.$bookingID.'"');
$timestamp = mysql_fetch_array($get_date);
$timestamp = $date['timestamp'];

$timestamp = date('D-M-Y',$timestamp);
//$timestamp is now a readable version of the timestamp date in the database
?>

the good thing about using timestamps is that if you want to order the items in your database by date you can do it easily. Also if you want to get bookings within the last month, do something like this:

$now = time();
$oneMonthInSeconds = 2629743;
$lastmonth = …
MDGM 22 Posting Whiz in Training

Ahhh i know whats going wrong. This bit:

foreach($result_array as $key => $value)
{
echo '<tr><td>Start Date</td><td>'.$result_array['startdate'].'</td></tr>';
echo '<tr><td>End Date</td><td>'.$result_array['enddate'].'</td></tr>';
echo '<tr><td>Adults</td><td>'.$result_array['adults'].'</td></tr>';
echo '<tr><td>Children</td><td>'.$result_array['children'].'</td></tr>';
echo '<tr><td>Roomtype</td><td>'.$result_array['roomtype'].'</td></tr>';
echo '<tr><td>Requirements</td><td>'.$result_array['requirements'].'</td></tr>';
}
echo '</table>';

is saying that for every piece of information saved inside the results array, write a table with the results. Take that out of the foreach function and have it on its own. Here how the whole code should look:

<?php

// open database connection code and then my code as follows

$sql="UPDATE bookings SET startdate ='$_POST[startdate]',enddate='$_POST[enddate]',adults='$_POST[adults]',children='$_POST[children]',roomtype='$_POST[roomtype]', requirements='$_POST[requirements]'
WHERE bookingID = '$_POST[bookingID]'";
 
if (!mysql_query($sql,$con))
  {
  die('Error:  ' . mysql_error());
  } 

  print "Your booking ID ".$bookingID;
  
  echo "    has been changed";


$result = mysql_query("SELECT * FROM bookings WHERE bookingID='".$_POST['bookingID']."'");


$result_array = mysql_fetch_array($result);

echo '<table border=1>';
echo '<tr><td>Start Date</td><td>'.$result_array['startdate'].'</td></tr>';
echo '<tr><td>End Date</td><td>'.$result_array['enddate'].'</td></tr>';
echo '<tr><td>Adults</td><td>'.$result_array['adults'].'</td></tr>';
echo '<tr><td>Children</td><td>'.$result_array['children'].'</td></tr>';
echo '<tr><td>Roomtype</td><td>'.$result_array['roomtype'].'</td></tr>';
echo '<tr><td>Requirements</td><td>'.$result_array['requirements'].'</td></tr>';
echo '</table>';


mysql_close($con);
?>

The query returned 9 pieces of information and stored them inside an array. Then the foreach function was going through all nine items in the array and printing your table of results

MDGM 22 Posting Whiz in Training

Thats really wierd..

Can you send the entire code to me?

MDGM 22 Posting Whiz in Training

try using this:

$result = mysql_query("SELECT * FROM bookings WHERE bookingID='".$_POST['bookingID']."'");

sometimes when you don't encapsulate the second part of the where condition in speech marks it treats it like a search term when your saying "select * from bookings where bookingID like '%term%'

MDGM 22 Posting Whiz in Training

Ah okay I understand.

the only possible reason for this, is that in your database, you are searching for all records where the bookingID is 33. You must have 9 different records that fit this description.

You have 2 options here:
- Add "LIMIT 1" to the end of your query, however this will limit the result to one row, but might get the wrong one...
- Change the bookingID column in your table to an auto increment primary key (http://grafax.co.uk/OTHER/max/daniweb/primarykey_AI-autoincrement.bmp)

It would also help if you sent me your whole code now too, and mayeb a screenshot of your database setup.

Max

MDGM 22 Posting Whiz in Training

I dont think I can explain it easily.

I basically want to encapsulate this:

$get_photos = mysql_query('SELECT * FROM images');//get all photos
while($photos = mysql_fetch_array($get_photos) )
{
     $get_ratings = mysql_query('SELECT COUNT(fbid) FROM ratings WHERE fbid = "'.$photos['fbid'].'" ');
     $ratings = mysql_fetch_array($get_ratings);
     if($ratings['COUNT(fbid)'] > 150){//if they have more than 150 ratings
          echo 'We can use this photo';//we want to use it
     }
     else{
          continue;//otherwise ignore it
     }
}

into a single mysql query...

MDGM 22 Posting Whiz in Training
<?php

//do your query
$result = mysql_query("SELECT * FROM bookings WHERE bookingID='".$last_insert_booking_id."'");

//because your query uses a primary key, we only have one result and so don't have to use the while function. instead, save all the query results into an array.
$result_array = mysql_fetch_array($result);

echo '<table>';
//for each piece of information saved in the array, display it to the user.
foreach($result_array as $key => $value)
{
	echo '<tr><td>Start Date</td><td>'.$result_array['startdate'].'</td></tr>';
	echo '<tr><td>End Date</td><td>'.$result_array['enddate'].'</td></tr>';
	echo '<tr><td>Adults</td><td>'.$result_array['adults'].'</td></tr>';
	echo '<tr><td>Children</td><td>'.$result_array['children'].'</td></tr>';
	echo '<tr><td>Roomtype</td><td>'.$result_array['roomtype'].'</td></tr>';
	echo '<tr><td>Requirements</td><td>'.$result_array['requirements'].'</td></tr>';
}
echo '</table>';

?>

what do you mean:
BTW is it possible for my to write the row titles rather than retrieving them from the table.


Max