-
Posts
1,437 -
Joined
-
Last visited
Never
Posts posted by papaface
-
-
<?php echo getcwd(); ?>
-
I'm not doing them all, but follow the principle:
<?php $states = array("AK"=>"Alaska","AL"=>"Alabama"); ?> <select id="sstate" name="sstate"> <?php foreach ($states as $k => $v) { ?> <option <?php if($shipping_state == $k){echo'selected="selected" ';} ?> value="<?php echo $k;?>"><?php echo $v;?></option> <?php } ?> </select>
-
Your not posting the form data.
<form action="Ex4-04-test.php" method="get">
should be
<form action="Ex4-04-test.php" method="POST">
-
No idea what you are trying to achieve here. If you want to display the real character use html_entitity_decode as you suggested.
<?php echo html_entity_decode("’"); ?>
Not entirely sure what your problem is.
-
Try
<?php $numWanted = trim($_POST['num_wanted']); // create an array of numbers called $numArray $numArray = array(12, 0, 89, 64, 23, 50); ?> <?php // use the array_search function to check if the number entered is in the array if(in_array($numWanted, $numArray) ) { echo "YES"; } else { echo "NO"; } ?>
-
<?php $string_to_be_stripped = "STRIP £$%^&*( ME $%^&*("; $new_string = ereg_replace("[^A-Za-z0-9 ]", "", $string_to_be_stripped ); echo $new_string;// STRIP ME ?>
-
Try http://uk2.php.net/htmlentities instead of htmlspecialchars()
-
what if the it's like
hey guys check out this site at http://www.frozenoven.com
Or you could just do:i wrote a similar script a while back here is a modified version
<?php function link_url($url) { $url_href = substr($url, 0, 7) != "http://" ? "http://{$url}" : $url; return "<a href=\"{$url_href}\" rel=\"nofollow\">{$url}</a>"; } echo "<pre>"; $string = "hey guys check out this site at http://www.frozenoven.com http://www.test.com www.dsa.com www.asd.com"; //for http:// $count = substr_count($string, "http://"); $start = 0; $len = 0; for ($i = 1; $i <= $count; $i++) { $start = strpos($string, "http://", $start + $len + 27); $len = strpos($string . " ", " ", $start) - $start; $url = substr($string, $start, $len); $string = str_replace(" " . $url, " " . link_url($url), $string, $asd); } //for www $count = substr_count($string, " www."); $start = 0; $len = 0; for ($i = 1; $i <= $count; $i++) { $start = strpos($string, " www.", $start + $len) + 1; $len = strpos($string . " ", " ", $start) - $start; $url = substr($string, $start, $len); $string = str_replace(" " . $url, " " . link_url($url), $string, $asd); } var_dump($string); ?>
Scott.
<?php $subject = "hey guys check out this site at http://www.frozenoven.com"; preg_match('/\\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i', $subject,$matches); echo $matches[0]; ?>
Will echo http://www.frozenoven.co
-
if ($q["kasutaja"]==$kasutaja && $q["parool"]==$parool) <--- or here { $_SESSION["sees"];
What does this session var do? I can see it isn't being assigned to anything.
-
We can quite clearly see you should be using $rows but you're not.while ($rows=mysql_fetch_assoc($validate)) { $_SESSION['login']=TRUE; $_SESSION['userid']=$row['id']; $_SESSION['primeiro_nome']=$row['primeiro_nome']; $_SESSION['ultimo_nome']=$row['ultimo_nome']; $_SESSION['Email']=$row['Email']; }
You're using $row when you should be using $rows.
while ($rows=mysql_fetch_assoc($validate)) { $_SESSION['login']=TRUE; $_SESSION['userid']=$rows['id']; $_SESSION['primeiro_nome']=$rows['primeiro_nome']; $_SESSION['ultimo_nome']=$rows['ultimo_nome']; $_SESSION['Email']=$rows['Email']; }
-
<?php $input = $_POST['msg']; $postdate = date('D, d M Y H:i:s T'); $data = $postdate . " " . $input; $file = 'filepath/data.dat'; $fh = fopen($file, 'a') or die('Could not open file!'); fwrite($fh, $data) or die('Could not write to file'); fclose($fh); ?>
-
Show us code.
-
Third time lucky lol, its late here:Sorry, my above code should have been:
$options = array("Lundi","Mardi","Mercredi","Jeudi","Vendredi"); echo '<select class="label_form1 " name="Jour1">'; foreach ($options as $k => $v) { ?> <option value="<?php echo $v; ?>" <?php if ($_SESSION['Jour1'] == "Vendredi") {echo "selected" ; }?>><?php echo $v; ?></option> <?php } echo '</select>';
$options = array("Lundi","Mardi","Mercredi","Jeudi","Vendredi"); echo '<select class="label_form1 " name="Jour1">'; foreach ($options as $k => $v) { ?> <option value="<?php echo $v; ?>" <?php if ($_SESSION['Jour1'] == $v) {echo "selected" ; }?>><?php echo $v; ?></option> <?php } echo '</select>';
-
-
I think the point of the OPs post is to not allow people to post HTML tags to his/her script. I think we're deviating from the subject a bit. The facts of the matter are that the OP did not ask for the HTML to be shown in entity form,. but he DID ask for the HTML to be removed, which I think I have provided the code for.
-
I think you'll find it is HTML but in its raw form. I think everyone else will agree with me that you're not actually removing anything at all. The OP should clarify.He never said anything about stripping tags. He said "remove html". Which is what htmlentities( ) will do.
<span style="font-size:10px; font-weight:bold;">Hello <em>World</em></span>is not html.
-
Exactly, its not actually stripping the html tags at all. Its just replacing them with the entities.No. That will produce:
<span style="font-size:10px; font-weight:bold;">Hello <em>World</em></span>
-
That will produce:Or
$string = htmlentities("<span style=\"font-size:10px; font-weight:bold;\">Hello <em>World</em></span>"); echo $string;
<span style="font-size:10px; font-weight:bold;">Hello <em>World</em></span>
which is not what the OP wants.
-
If you need to remove absolutely all spaces keep your str_replace().I thought trim only got rid of spaces at the beginning or end, not in the middle?
-
I've already done that for you....That's what I feared you'd answer
Thanks. There's no way a lazy programmer like myself will write 50 lines of code for that single purpose!
Let's make a function to find out which option needs a "selected='true'"
A loop ? hmm.
How about javascript guys? do you think it could be easier to write a javascript to assign new values to the form?
since javascript has acces to all page's elements
-
Sorry, my above code should have been:
$options = array("Lundi","Mardi","Mercredi","Jeudi","Vendredi"); echo '<select class="label_form1 " name="Jour1">'; foreach ($options as $k => $v) { ?> <option value="<?php echo $v; ?>" <?php if ($_SESSION['Jour1'] == "Vendredi") {echo "selected" ; }?>><?php echo $v; ?></option> <?php } echo '</select>';
-
<select class="label_form1 " name="Jour1"> <option value="Lundi" <?php if ($_SESSION['Jour1'] == "Lundi") {echo $_SESSION['Jour1'] ; }?>>Lundi</option> <option value="Mardi" <?php if ($_SESSION['Jour1'] == "Mardi") {echo $_SESSION['Jour1'] ; }?>>Mardi</option> <option value="Mercredi" <?php if ($_SESSION['Jour1'] == "Mercredi") {echo $_SESSION['Jour1'] ; }?>>Mercredi</option> <option value="Jeudi" <?php if ($_SESSION['Jour1'] == "Jeudi") {echo $_SESSION['Jour1'] ; }?>>Jeudi</option> <option value="Vendredi" <?php if ($_SESSION['Jour1'] == "Vendredi") {echo $_SESSION['Jour1'] ; }?>>Vendredi</option> </select>
Only other option is to do:
$options = array("Lundi","Mardi","Mercredi","Jeudi","Vendredi"); echo '<select class="label_form1 " name="Jour1">'; foreach ($options as $k => $v) { echo '<option value="'.$v.'" '.if ($_SESSION['Jour1'] == '.$v.') {echo $_SESSION['Jour1'] .'>'.$v.'</option>'; } echo '</select>';
-
yes.
In the page it is submitted to after validation have:
session_start(); foreach ($_POST as $k => $v) { if ($k != "submit")//excludes the submit button named "submit" change accordingly { $_SESSION[$k] = $v; } }
That will assign every $_POST var a corresponding $_SESSION variable.
Then it is just a case of:
<?php session_start();?> <input class="label_form1" type="text" name="Prénom" value="<?php if ($_SESSION['Prénom']) {echo $_SESSION['Prénom']; }?>" /><br />
Done.
-
Sir, i say sir, you are a genius
Thanks, as a side note.
str_replace(' ', '', $string)
is not required when using trim(). So use:
<?php $string = " "; $string = trim($string); if(empty($string)) { echo "empty!"; } else { echo "spacy, i say"; } ?>
[SOLVED] strip chars
in PHP Coding Help
Posted