`

<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

<?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" />
?>
Member Avatar for diafol

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

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.

<?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">

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.

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>";
commented: wow nice link :) thanks. +1

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>";
Member Avatar for diafol

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'.

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.

commented: good points +7
Member Avatar for diafol

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.

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?

.crashed

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.

commented: I didn't know the comma trick. Thanks +7

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,

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>';
commented: thanks. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.