0

`

<form action="ScoreCardAlpha.php" method="post">
A: <input type="text" name="$X" /> 
B: <input type="text" name="$Z" />
C: <input type="text" name="$W" />

// read input data on $W , $X and check to see if (it or they{1,2,3 and byond}) has http// if so save after //

// check all data for hacks.
<input type="play$" />

` is thats what is known as a funcion or do i have to find a method or use an areay ? if so could you point me to an easy to translate guide, thanks.


` call scenario $123/45/9 {the pink n yellow whole in the ground started to form a bridge

Edited by Kniggles: n/a

3
Contributors
15
Replies
17
Views
7 Years
Discussion Span
Last Post by mschroeder
Featured Replies
  • [QUOTE][CODE]<?php <form action="ScoreCardAlpha.php" method="post"> A: <input type="text" name="$X" /> B: <input type="text" name="$Z" /> C: <input type="text" name="$W" /> // read input data on $W , $X or $Z has http// if so save after // if(!filter_has_var(INPUT_post, "$X")) { // if true **** deleate all char upto and including // … Read More

  • There are a lot of different ways to attack this: [url]http://refactormycode.com/codes/598-remove-http-from-url-string[/url] has a whole variety of them. Some are good some are bad, my suggestion is to avoid regular expressions unless they're absolutely necessary. [CODE] <?php /* E.g: $s = 'http://google.com'; echo remove_http($s); output: google.com */ function remove_http($url = '') … Read More

  • with the exception that http:// could be repeated multiple times within the url. in which case that would fail. It all depends on the use case. [ICODE]$url = 'http://www.site.com/url.php?url=http://www.google.com';[/ICODE] You would also probably want to use str_ireplace as the user supplied url could very well be Http:// HTTP:// hTtP:// etc. Read More

  • 1
    diafol 3,720   7 Years Ago

    That's a fair point ms - that's why I said it was a dirty fix. And yes, I agree, the 'i' version would be better. Read More

  • [CODE] echo "<td><a class=\"mylink\" 'http://' href=\"http://" . $row['website'] . "\">" . $row['website'] . "</a></td>"; echo "<td><img width = '75' src=". $row['url'] . " /></td>"; [/CODE] For starters if you're going to be echoing HTML, single quotes will make your life much easier. You also have an unnecessary 'http://' in between … Read More

0
<?php

<form action="ScoreCardAlpha.php" method="post">

A: <input type="text" name="$X" />

B: <input type="text" name="$Z" />

C: <input type="text" name="$W" />

// read input data on $W , $X or $Z has http// if so save after //

if(!filter_has_var(INPUT_post, "$X"))
 {
// if true
	**** deleate all char upto and including // then post to "$X"  ****
 echo("Input has been adapted and saved");
 }
else
 {
// if false
	**** post to "$X" ****
 echo("Input did not need adapting and has been saved");
 }

<input type="submit" />
?>

Edited by Kniggles: added button

0

if(!filter_has_var(INPUT_POST, "$X"))

What are you trying to do, I don't understand:

is thats what is known as a funcion or do i have to find a method or use an areay ? if so could you point me to an easy to translate guide, thanks.

call scenario $123/45/9 {the pink n yellow whole in the ground started to form a bridge

0

if(!filter_has_var(INPUT_POST, "$X"))

What are you trying to do, I don't understand:

I have a box to input an image url,

form 1 =

" URL: <input type="text" name="url" /> "

-----------------------------
process form =

$sql="INSERT INTO table1( url )
VALUES
('$_POST[url]')";

--------------------------------

output form =

echo "<td><img width = '75' src='http://". $row['url'] . "' /></td>";

------------------------------------------------
this however ends up with a broken link unless the ' http:// ' is not input. {thus i am trying to filter out the http:// and any bad code at the same time.

Also i am trying to make the image clickable.

1
<?php

<form action="ScoreCardAlpha.php" method="post">

A: <input type="text" name="$X" />

B: <input type="text" name="$Z" />

C: <input type="text" name="$W" />

// read input data on $W , $X or $Z has http// if so save after //

if(!filter_has_var(INPUT_post, "$X"))
 {
// if true
	**** deleate all char upto and including // then post to "$X"  ****
 echo("Input has been adapted and saved");
 }
else
 {
// if false
	**** post to "$X" ****
 echo("Input did not need adapting and has been saved");
 }

<input type="submit" />
?>

Maybe I am missing something, but I don't see how the code you provided can even execute. You should get a parse error as soon as it gets to the "<" in <form action="ScoreCardAlpha.php" method="post">

0

Maybe I am missing something, but I don't see how the code you provided can even execute. You should get a parse error as soon as it gets to the "<" in <form action="ScoreCardAlpha.php" method="post">

that part was put in for my mental notes, the part i know that needs the fix is

echo "<td><img width = '75' src='http://". $row['url'] . "' /></td>";

I can get the pics up and displayed in a 75 box, so long as you dont copy the http:// part.
this is silly az to get the image url its easy to copy n paste it,

also when the pic is pisplayed its not clickabale.

so therefor its either something in the upload script or output script that needs to be changed.

1

There are a lot of different ways to attack this: http://refactormycode.com/codes/598-remove-http-from-url-string has a whole variety of them. Some are good some are bad, my suggestion is to avoid regular expressions unless they're absolutely necessary.

<?php
/*
E.g:
$s = 'http://google.com';
echo remove_http($s);
output: google.com
*/

function remove_http($url = '')
{
    array('http://', 'https://');
    foreach ($list as $word)
        if (strncasecmp($url, $word, strlen($word)) == 0)
            return substr($url, strlen($word));
    return $url;
}

Would probably be my choice from that link for how to do this accurately.
Your images are not clickable because there are no links around them.
They would need to be something like:

echo "<td><a href="someurl.com"><img width = '75' src='http://". $row['url'] . "' /></a></td>";
Votes + Comments
wow nice link :) thanks.
0

if(!filter_has_var(INPUT_POST, "$X"))

What are you trying to do, I don't understand:

sumting like that,

\\ this line reads input and surches to see if http:// is added

$var= {" `any char` `any char` {loop untill . "http://"} "} 

if ($input_post){ = includes} $var

\\ this line deleats every thing before http://
then $X = everything after $var

else

$X = $input_post

or

\\ this only outputs a image if http:// is not in the post form allready.
echo "<td><img width = '75' src='http://". $row['url'] . "' /></td>";
0

If you're just trying to delete 'http://' from a string, there are easier methods. mschroeder has outlined a nice one. I'd use str_replace myself:

$url = str_replace("http://","",$url);

It's not pretty, but should work. It replaces "http://" with a 'nothing'.

1

with the exception that http:// could be repeated multiple times within the url. in which case that would fail. It all depends on the use case. $url = 'http://www.site.com/url.php?url=http://www.google.com'; You would also probably want to use str_ireplace as the user supplied url could very well be Http:// HTTP:// hTtP:// etc.

Votes + Comments
good points
1

That's a fair point ms - that's why I said it was a dirty fix. And yes, I agree, the 'i' version would be better.

0

Now have image and a link displayed in a table,
am now trying to make the image clickable to the link

echo "<td><a class=\"mylink\" 'http://' href=\"http://" . $row['website'] . "\">" . $row['website'] . "</a></td>";
 
echo "<td><img width = '75' src=". $row['url'] . " /></td>";

have been trying mschroeder

echo "<td><a href="someurl.com"><img width = '75' src='http://". $row['url'] . "' /></a></td>";

like

echo "<td><a href="$row['website']"><img width = '75' src=". $row['url'] . " /></a></td>";

anyone see where i am messing it up please?

2
echo "<td><a class=\"mylink\" 'http://' href=\"http://" . $row['website'] . "\">" . $row['website'] . "</a></td>";
 
echo "<td><img width = '75' src=". $row['url'] . " /></td>";

For starters if you're going to be echoing HTML, single quotes will make your life much easier. You also have an unnecessary 'http://' in between your class and href attributes.

echo '<td><a class="mylink" href="http://',$row['website'],'">',$row['website'],'</a></td>';
echo '<td><img width="75" src="',$row['url'],'"/></td>';

Also unless you absolutely NEED to append the strings together, passing multiple strings and delimiting them with a comma will speed things up. This only works with echo and not print.

Votes + Comments
I didn't know the comma trick. Thanks
0

Also unless you absolutely NEED to append the strings together, passing multiple strings and delimiting them with a comma will speed things up. This only works with echo and not print.

have got that , and it works,

still have not got the image clickable to the ['website'] link,

Edited by mike_2000_17: Fixed formatting

1

Edit: The problem is that you don't have the img tag wrapped with an a tag.

echo '<td><a class="mylink" href="http://',$row['website'],'">',$row['website'],'</a></td>';
echo '<td><a class="mylink" href="http://',$row['website'],'"><img width="75" src="',$row['url'],'"/></a></td>';

Edited by mschroeder: n/a

Votes + Comments
thanks.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.