We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,613 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Is this madness a mefford or called a function ?

`

<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

3
Contributors
15
Replies
2 Days
Discussion Span
2 Years Ago
Last Updated
16
Views
Question
Answered
Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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" />
?>
Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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

diafol
Keep Smiling
Moderator
10,613 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

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.

Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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" />
?>

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

mschroeder
Work Harder
Team Colleague
673 posts since Jul 2008
Reputation Points: 281
Solved Threads: 133
Skill Endorsements: 5

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.

Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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>";
mschroeder
Work Harder
Team Colleague
673 posts since Jul 2008
Reputation Points: 281
Solved Threads: 133
Skill Endorsements: 5

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>";
Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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'.

diafol
Keep Smiling
Moderator
10,613 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

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.

mschroeder
Work Harder
Team Colleague
673 posts since Jul 2008
Reputation Points: 281
Solved Threads: 133
Skill Endorsements: 5

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.

diafol
Keep Smiling
Moderator
10,613 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

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?

Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

.crashed

Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
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.

mschroeder
Work Harder
Team Colleague
673 posts since Jul 2008
Reputation Points: 281
Solved Threads: 133
Skill Endorsements: 5

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,

Kniggles
Junior Poster in Training
96 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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>';
mschroeder
Work Harder
Team Colleague
673 posts since Jul 2008
Reputation Points: 281
Solved Threads: 133
Skill Endorsements: 5
Question Answered as of 2 Years Ago by mschroeder and diafol

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1416 seconds using 2.73MB