Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2012, 10:59 AM   PM User | #1
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
hide contact details

I want to hide letters from a text and reveal them when I click a button.

I have contact details which I want to look like this:

contact@yo***********
+49089**************
Street. Kenn**********


and when I click "Show contact" I want to show the entire words.

Ty
_user is offline   Reply With Quote
Old 02-21-2012, 04:02 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 362 Times in 361 Posts
sunfighter is on a distinguished road
Do a search on this. It's been answered billions and billions of times. Search bar just above your head.
sunfighter is offline   Reply With Quote
Old 02-21-2012, 04:15 PM   PM User | #3
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
search for what?
how is it called?
do you think I would still ask if I knew what is called?
_user is offline   Reply With Quote
Old 02-23-2012, 08:18 PM   PM User | #4
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 362 Times in 361 Posts
sunfighter is on a distinguished road
OK. I've been called name on this and don't want things to escalate any further.
This is how I would do this. I assume only some users will be able to see the entire text without the *'s so I have used ajax, checked for authorization, and changed the div display.
Two files. This is the called php
test_3.php:
Code:
<?php
session_start();
	$fir = "contact@yourmommas.com";
	$firs = "+4908909876545678";
	$first = "Street. Kenny Ave. West Burrow, N.M.";
	$NewMessage = $fir . '<br />' . $firs . '<br />' . $first;
	$Message = substr($fir, 0, 10).'***********<br />'.substr($firs, 0, 6).'**************<br />'.substr($first, 0, 12).'**********';

if($_SESSION["user"] == 'yes')
{
	echo $NewMessage;
}else{
	echo $Message;
}
?>
This is the main page
local.php:
Code:
<?php
session_start();
$_SESSION['user']= 'yes';
$fir = "contact@yourmommas.com";
$firs = "+4908909876545678";
$first = "Street. Kenny Ave. West Burrow, N.M.";
$Message = substr($fir, 0, 10).'***********<br />'.substr($firs, 0, 6).'**************<br />'.substr($first, 0, 12).'**********';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>New document</title>
<script type="text/javascript">
function Show_words()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("home").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","test_3.php",true);
xmlhttp.send('');
}
</script>
</head>

<body>
<div id="home">
<?php
echo $Message;
?>
</div>
<input type="button" value="Reveal" onclick="Show_words();" />
<div id="hot"></div>
</body>
</html>
Walking hand in hand. Hope this helps.
sunfighter is offline   Reply With Quote
Old 02-24-2012, 06:34 AM   PM User | #5
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
yes its ok. and thank you.
but I have a problem...
what if the contacts are called from a db using autogenerated links?
how can I get rid of test php?

I have tried this... but doesn't work.

PHP Code:
<?php

include 'connect.php';

session_start();
    
$id $_GET['id'];
    
$fir $_GET['phone1'];
    
$firs $_GET['phone2'];
    
$first $_GET['adress'];
    
$NewMessage $fir '<br />' $firs '<br />' $first;
    
$Message substr($fir010).'***********<br />'.substr($firs06).'**************<br />'.substr($first012).'**********';

if(
$_SESSION["user"] == 'yes')
{
    echo 
$NewMessage;
}else{
    echo 
$Message;
}
?>




PHP Code:
session_start();
$_SESSION['user']= 'yes';
    
$id $_GET['id'];
    
$fir $_GET['phone1'];
    
$firs $_GET['phone2'];
    
$first $_GET['adress'];
$Message substr($fir010).'***********<br />'.substr($firs06).'**************<br />'.substr($first012).'**********'

Last edited by _user; 02-24-2012 at 08:21 AM..
_user is offline   Reply With Quote
Old 02-24-2012, 02:30 PM   PM User | #6
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 362 Times in 361 Posts
sunfighter is on a distinguished road
Quote:
what if the contacts are called from a db using autogenerated links?
What are autogenerated links?
Second this was made to get info from a db. Where else would it come from if you wanted it to be secret?

Quote:
how can I get rid of test php?
Don't know what you mean here either. Are you talking about the message strings? Are you talking about the file test_3.php? That is not a 'test' file, it's what the ajax function calls. It is necessary, you can rename it if you want and you should. Remember to change it in local.php also.

You should use different names for the codes not just 'php code'. I'm gonna call the top/first one local.php, OK? Why did you change it like that? You are not accessing a db but getting info from a form. Who's filling the form if it's not the user looking at the page.
local.php top sction:
Code:
<?php
session_start();  // get into the habit session_start FIRST LINE
include 'connect.php';
$_SESSION['user']= 'yes';  // This is really set when you log user and give him/her privileges

/* Query your db here!!!!!!! */

$row[0] = "contact@yourmommas.com"; // values added here by me because I don't have access to your db.
$row[1] = "+4908909876545678";      // You get these values from the above query
$row[2] = "+1234567890987654";
$row[3] = "Street. Kenny Ave. West Burrow, N.M.";
$Message = substr($row[0], 0, 10).'***********<br />'.substr($row[1], 0, 6).'**************<br />'.substr($row[2], 0, 6).'**************<br />'.substr($row[3], 0, 12).'**********';
?>
Your test_3.php:
Code:
<?php
session_start();
include 'connect.php';
/*$_SESSION['user']= 'yes';*/ // This is set in your online pages Not Here

/* Query your db here!!!!!!! */

$row[0] = "contact@yourmommas.com";
$row[1] = "+4908909876545678";
$row[2] = "+1234567890987654";
$row[3] = "Street. Kenny Ave. West Burrow, N.M.";
$NewMessage = $row[0] . '<br />' . $row[1] . '<br />' . $row[2] . '<br />' . $row[3];
$Message = substr($row[0], 0, 10).'***********<br />'.substr($row[1], 0, 6).'**************<br />'.substr($row[2], 0, 6).'**************<br />'.substr($row[3], 0, 12).'**********';
if($_SESSION["user"] == 'yes')
{
	echo $NewMessage;
}else{
	echo $Message;
}
?>
sunfighter is offline   Reply With Quote
Old 02-24-2012, 03:22 PM   PM User | #7
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
I have a dropdown menu from where users selects 2 words and make a search for them. (color and size)
the query is something like that
Code:
" SELECT * FROM table WHERE color LIKE  '%$color%'  AND  size LIKE '%$size%'"
It list the query, and than I use
PHP Code:
<a href="product.php?id=" $row['ID'] . "\"> 
and this is "autogenerated link" because it's not a file and I don't know how to call it

so....

on product.php?id=1
i list data from db including contact details.
and I try to transform "your data" (your example: contact@yourmommas.com) in strings to call from db same time with the rest of the info (description, etc) listed automatic on product.php?id=1


test = test_3.php


the code works fine...
but I can't adapt it to my needs... or... I don't know how.... yet ! (still tryin and learning)
_user is offline   Reply With Quote
Old 02-24-2012, 11:30 PM   PM User | #8
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 362 Times in 361 Posts
sunfighter is on a distinguished road
Post the code you are going to use to populate the Xd out strings.
Don't use SELECT *
select the items you want like
SELECT 'id', 'phone1', 'phone2', 'adress' FROM .... WHERE...
sunfighter is offline   Reply With Quote
Old 02-25-2012, 08:47 AM   PM User | #9
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
include connection
defining strings
query

and

PHP Code:
    if(!isset($_POST['submit'])) {
        if (!
is_numeric($_GET['id'])) {
    die(
"Oh dear. Non-numeric id detected");

        
$q "SELECT * FROM table WHERE ID = $_GET[id]";
        
$result mysql_query($q);

    }

    echo 
"  <table width='100%' border='0'>";
while(
$row mysql_fetch_array($result)){
echo 
"blablablabla (here is populating the page)"
?> 
_user is offline   Reply With Quote
Old 02-25-2012, 03:03 PM   PM User | #10
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 362 Times in 361 Posts
sunfighter is on a distinguished road
OK, I give up. Your going to get information WHERE ID = $_GET[id] and then hide it from $_GET[id] with xxx's. It makes no sense. Why hid something he knows?
sunfighter is offline   Reply With Quote
Old 02-26-2012, 10:49 AM   PM User | #11
_user
New Coder

 
Join Date: Nov 2011
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
_user is an unknown quantity at this point
I don't know what you don't understand. I don't know how to explain otherwise.
The point is that I wanna count how many times a user acces a contact details of each page. I don't wan't count views of page, just how many time he acces the contact details. Now makes sens?
_user is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:32 PM.


Advertisement
Log in to turn off these ads.