PHP - How To Make @username To A Link?
Hey,
What i want is that if a username inserts some text into a field like "Hey @martin how are ya" ? then it will display @martin as a link that takes you to site.com/martin, i searched php.net from preg_replace and str_replace...unfortunately for me things got so complicated that i don't even want to talk about it. Anyone who can do it will be my saviour! Similar Tutorials
Using Inline Php; <h1><font Color="000088">the Username <?php '.$username.' ?> Already Exists";</h1>
ISSUE. A User enters information into a form. If the 'username' is already taken, a 'message' in Red and with larger font-size will be returned, for example, "The username $username already exists." If the username is 'mattd' then the message should say, "The username mattd already exists." Within my php application, I have included 'inline html'. Here is part of the code: .... if (mysql_num_rows($query_run)==1) { // it will never = more than one because only //one user will or will not exist ?> <html> </body> <h1><font color="#FF0066">The username <?php echo $username; ?>already exists.</h1> </body> </html> <?php }else{ //start the registration process $query = "INSERT INTO `Names` VALUES .... 1. At one point I did get this: "The username mattd already exists." 2. But now I only get "The username already exists." I am not retrieving the $username variable. This screenshot is found he http://imgur.com/lIwLZ1G thanks. While we're on the subject, is there a way to ensure that the first letter of a name is captalized, and the rest lowercase? Or is this best handled later on, when the name is being used and called from the DB. PS: some of us comment are code as to WHAT we are doing because we're just not that good yet, and we need to explain it to ourselves. I have created a database that echos out the result on a webpage, what i want to do is create one of the echo results into a link - the code is as follows: "Web Address: $web_address <br>" . Is there an easy way to make the result a link as the input will always be a web address? Thanks in advance! ok, how do I make this button go to the specific link that is set with it.......it goes to page without eventid=eventid: Code: [Select] <form action= \"editevent.php?eventid=".$row['eventid']."\" method=\"link\"><INPUT TYPE=\"submit\" VALUE=\"Edit\"></form>"; This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=307669.0 Lets say that I want to make a certain word (or words) on a page a link. How would I make it a link without having to code in a link. Some site have adds on certain words; one day and not the next day. I am looking for similar feature, but less intrusive. No pop-up, just a link. I would like to know how to make my links show that it's active. For example if I click on a link that says overview then that link has to be highlighted. This is the code that I have: Code: [Select] <?php if (isset($this->_params['submenus']) && is_array($this->_params['submenus'])){ foreach ($this->_params['submenus'] as $submenu){ ?> <li class="active"><a href="<?php echo $this->get_uri("/{$submenu['controller']}/{$submenu['action']}") ?>" onclick="javascript:return setSubMenu(<?php echo $submenu['id'] ?>);"><?php echo strtoupper($submenu['name'])?></a></li> <?php } } ?> Unfortunately with this code all the links are selected as active. I have a table where it displays some data. How do I make this Code: [Select] echo "<td>" . $row['title'] . "</td>"; into a link? I basically have a PHP Search Form, and when a user fills in a form it outputs the results. Each result displays a image of a property, how could i make them images have their own unique link which will take them directly to the page of the property being shown? Im using PHP and mySQL tables Any help is appreciated, Thank You. Heres the PHP that outputs the results: Code: [Select] <?php require_once 'mstr_ref.php'; function san($input){ if(get_magic_quotes_gpc()){ $input=stripcslashes($input); } $output = mysql_real_escape_string($input); return $output; } if(isset($_POST['submit'])){ $pVars = array('area'=>$_POST['areas'], 'propType'=>$_POST['prop_type'], 'saleType'=>$_POST['ptype'], 'minB'=>$_POST['min_bedrooms'], 'maxB'=>$_POST['max_bedrooms'], 'minP'=>$_POST['min_price'], 'maxP'=>$_POST['max_price']); foreach ($pVars as $k=>$v){ $v = san($v); } $sql = new makeQuery(); $sql->manAdd('location_id', $pVars['area']); if($pVars['propType'] != 'Any'){ $sql->manAdd('catagory_id', $pVars['propType']); } if ($pVars['maxB'] > 0){ $sql->manAdd('bedrooms', $pVars['maxB'], '<='); } if($pVars['minB'] > 0){ $sql->manAdd('bedrooms',$pVars['minB'],'>='); } if($pVars['saleType'] != 'Any'){ if($pVars['saleType'] == "forsale"){ $sql->manAdd('market_type', 'sale'); if($pVars['minP'] != 0){ $pVars['minP'] = $pVars['minP'] * 1000; } if($pVars['maxP'] != 0){ $pVars['maxP'] = $pVars['maxP'] * 1000; } } if($pVars['saleType'] == 'forrent'){ $sql->manAdd('market_type', 'rent'); } } $qry = $sql->sqlStart.$sql->stmt.'Group By property.id'; $results = mysql_query($qry) or die (mysql_error()."<br />|-|-|-|-|-|-|-|-|-|-|-|-<br />$qry"); if(mysql_num_rows($results) < 1){ die ("Sorry, No Results Match Your Search."); } while($row = mysql_fetch_assoc($results)){ echo '<div class="container" style="float:left;">'; echo '<div class="imageholder" style="float:left;">'; echo "<img class='image1' src='{$row['image_path']}' alt='{$row['summary']}'> <br />"; echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:14px; float:left; padding-top:10px;">'; echo "{$row['summary']}"; echo "<span style=\"color:#63be21;\"><br><br><b>{$row['bedrooms']} bedroom(s) {$row['bathrooms']} bathroom(s) {$row['receptions']} reception room(s)</b></span>"; if($row['parking'] != null){ echo "<span style=\"color:#63be21;\"><b> {$row['parking']} parking space(s)</b></span>"; } echo '</div>'; echo '<div style="clear:both"></div>'; } } else{ echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again"; } ?> I have a site, and there is an image with a link to another page, how can I make it so this is the only way to get to that page is by clicking on that image, and not by typing www.mywebsite.com/page.php into the address bar in a browser? Hi I would like to know how to make a link select certain stuff from the database. For example the link called cape town with the id 11 is selected then the link must search through the events table for the city_id 11 and take that information and display it in another page. I would like to know how to do that or can you let me know of place that I can look. I have tried google but I don't know how to put what I'm looking for in words Seems to be a basic question, but I couldn't find an answer nor figure it out on my own. Basically I have a script that takes out specific data out of the database, the script works on its own, now I just need a way to make the user execute it with a link or a button. Example: Category: [Smileys] - [Category2] - [Category3] - etc. As soon as the user clicks on [Smileys] all data in the database which contains the word smileys in the category field gets selected and outputted as a list. Again the script works, I just need to be able to execute it with a button. If I understood it correctly I have to run the script by adding a if (isset($_POST['Smileys'])) { in front of the script. But how do I build the connection with the text link? Hi People. I am doing quite well with my www.airfieldcards.com website which is information for pilots in the UK and ireland should they wish to visit another airfield. It is in the form of a flight guide for free. Each card is held in a database and the cards are shown on the site by loading the following script /php/results.php?id=132 In the above example the card for c-moor in Ireland would be loaded. I want to be able to add a link within the cards that will give the user "the code" to enter that card within their own website. Sort of a "click here to get the code to add to your website" Then opening a separate box in a new window that had something like this in it. Copy and Paste the following code into your website Code: [Select] <iframe width="720" height="1500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://airfieldcards.com/php/results.php[b][i]"what goes here?"[/i][/b] What would I put into the bit "what goes here?" to dynamically load that specific card? and give the user the correct code to add into their own site? Thanks in advance, you guys on here have always been brilliant. This is the code I have now however when you click next to view more results it says please enter a search..., (there is more code above this however I thought that the problem would be within the code provided.) $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> Hi! I want to add the users nickname to the urlcode. I don't have any clue how to :O And maybe add more text after the url www.url.comTEXTusername echo $row["url"];$row["username"]; Please help Here's the class Code: [Select] <?php session_start(); class Train { private $_clicked; private $_name; function __construct() { $this->_name = (string) $_SESSION['nrpgusername']; $this->_clicked = (int) $_SESSION['clicked']; } public function CheckLogged() { if(isset($this->_name)) {} else{die("you must be logged in!");} } public function CheckClicked() { if(isset($_POST['go'])) { $this->MysqlUpdate(); $this->_clicked = 1; session_set_cookie_params(84600); } } public function Clicked() { if(isset($this->_clicked)) { echo' <div id="train"><img src="images/train.jpg" alt="train image"/></div> <div id="text"> <span id="click">' . $this->_name. ' has gained 7 experience,<br /> and cannot train anymore today. </span><form method ="post" name="train" action=""> </div>'; } else { echo' <div id="train"><img src="images/train.jpg" alt="train image"/></div> <div id="text"><span id="click">Click here to train your shinobi!</span> <form method ="post" name="train" action=""><input type="submit" name="go" value="train" /></div>';} } private function MysqlUpdate() { include("database.php"); $query = "UPDATE account_info SET experience = experience + 7 WHERE username = '$this->name'"; $result = mysql_query($query) or die(mysql_error()); } } ?> For some reason, it's showing 1 has gained 7 experience, and cannot train anymore today. Instead of Tony has gained 7 experience, and cannot train anymore today. Hi, I used to use the php session to get the username of the user that was logged on and use that variable on our intranet. Recently we are having to redevelop the site, and we can no longer use this variable. Is there another way of getting the username of the user who is logged onto the computer? Thanks in Advance, Stuart How to show the username of the person who uploaded something? I know how to make the upload script etc. but what is the script needed for the person's username and where do I put it? Thanks. I want to accomplish two things: save some server overhead and create a friendlier user experience. Thus, prior to form submission, the user should have the opportunity to check whether the chosen username is available. As I've begun researching the topic, I've discovered AJAX, Vue, and XMLHttpRequest alternatives.
Any suggestions and alternatives that would give me guidance would be appreciated.
Additionally, are there any characters that should be expressly prohibited from use in a username (or other input field) that could aid malicious hackers in causing harm to my website, database, and files?
|