1,076,329 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Latest Posts in Web Development

On line 38 you'll need something like this, assuming user_type is an integer column in your table:

$row = mysql_fetch_assoc($result);
switch ($row['user_type'])
{
    case 1: header(); break;
    case 2: header(); break;
    // etcetera
}
pritaeas
Posting Prodigy
Moderator
9,311 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86

Hi

I have some script that I have used for sometime so understand it is out of date code, but it works. I want to amend it so that it also checks a field user_type and on successful login directs each to a differnt page. The code at the moment takes username and password from a login page, checks it (code below) and either takes user to a main page if correct or tells them username or password is wrong.

<?php require_once('Connections/Connection1.php'); ?>

<?php
$tbl_name="users"; // Table name 



// Connect to server and select databse.
//mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
//mysql_select_db("$db_name")or die("cannot select DB");
mysql_select_db($database_Connection1, $Connection1);

// username and password sent from form 
$myusername=$_POST['myusername']; 
$mypassword=md5($_POST['mypassword']); 




// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE userid='$myusername' and 

password='$mypassword'";
$result=mysql_query($sql);


// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:main.php?myusername=".$myusername);
}
else {
header("location:login_failed.php");
//echo "Wrong Username or Password";
}
?>

Any help would be very much appreciated!

mdemetri2
Newbie Poster
1 post since May 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

It is supposed to rotate as per your code. Have you tried web-kits and moz-kit to make it compatible with the browsers? Maybe you're viewing it in a browser that does not support CSS3 properties. As with the block, well tables elements like td tr don't work on their own without any object placed within them.

crescendo
Newbie Poster
16 posts since May 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Well what it says is that you have not defined $id. $id is empty, and therefore you get an error and your script is not working. If you do not define $id in a way such as this:

$id = 'yourvalue';

Then it will be undefined and you will not be able to work with it. PHP cannot check your <div>'s id. You should use Javascript for that :). Does this answer your question?

minitauros
Posting Whiz
331 posts since Apr 2011
Reputation Points: 45
Solved Threads: 50
Skill Endorsements: 4

If I have dropdownlist as below

<select onChange="this.value;">  
  <option value="Volvo" id="volvo">Volvo</option>    
  <option value="Saab" id="saab">Saab</option>    
  <option value="VW" id="vw">VW</option>    
  <option id="audi" value="Audi" selected>Audi</option>                  
</select> 

I want to display discription of item selectd so I have below code

<div id="boxpopup" class="box">  
    <a onClick="closeOffersDialog('boxpopup');" class="boxclose"></a>  
    <div id="content">  
    This is popupbox of Audi   
    </div><!--end of content --> 
</div><!--end of popupbox -->     

now in content can I give If else as below

    <div id="boxpopup3" class="box">  
        <a onClick="closeOffersDialog('boxpopup');" class="boxclose"></a>  
        <div id="content"> 
            <?php if($id=="volvo"){ ?> 
            This is popupbox of Volvo
            <?php } elseif($id=="saab"){ ?>
            This is popupbox of Saab 
            <?php } elseif($id=="vw"){ ?>
            This is popupbox of VW 
            <?php } else { ?>
            This is popupbox of Audi
            } ?>
        </div><!--end of content --> 
    </div><!--end of popupbox -->

The error is occurs
Notice: Undefined variable: id
please help me :(

shilu2
Newbie Poster
16 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

You can also use array_key_exists

if(array_key_exists('category',$_GET)) {
    if(array_key_exists($_GET['category'], $myarray)) {
        echo $myarray[$_GET['category']];
    } else {
         echo 'not found in array';
    }
}

and shorter and not so pretty.....

if(array_key_exists('category',$_GET)) {
    echo array_key_exists($_GET['category'], $myarray) ? $myarray[$_GET['category']] : 'not found in array';
}

and shorter....and uglier.....

echo (array_key_exists('category',$_GET) AND array_key_exists($_GET['category'], $myarray)) ? $myarray[$_GET['category']] : 'not found in array';
paulkd
Junior Poster
130 posts since Aug 2007
Reputation Points: 39
Solved Threads: 24
Skill Endorsements: 0

Hi all,
I have taken from net drop down menu script
my web page is medistyle.az. It works perfectly
but when i look up code i cannot understand one thing there
below is code (js. file)

var menu=function(){
    var t=15,z=50,s=6,a;
    function dd(n){this.n=n; this.h=[]; this.c=[]}
    dd.prototype.init=function(p,c){
        a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
        for(i;i<l;i++){
            var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
            h.onmouseover=new Function(this.n+'.st('+i+',true)');
            h.onmouseout=new Function(this.n+'.st('+i+')');
        }
    }
    dd.prototype.st=function(x,f){
        var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
        clearInterval(c.t); c.style.overflow='hidden';
        if(f){
            p.className+=' '+a;
            if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
            if(c.mh==c.offsetHeight){c.style.overflow='visible'}
            else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
        }else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
    }
    function sl(c,f){
        var h=c.offsetHeight;
        if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
            if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
            clearInterval(c.t); return
        }
        var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
        c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
        c.style.height=h+(d*f)+'px'
    }
    return{dd:dd}
}();

Here i dont understand what does return{dd:dd} mean. I understand dd is name of function(class) but i couldnt understand what does syntax mean (return{dd:dd})
Thanks in advance for attention !!!

azegurb
Posting Whiz in Training
258 posts since Sep 2009
Reputation Points: 11
Solved Threads: 2
Skill Endorsements: 0

Hi thanks for reply. This isn't jQuery it's a class I wrote myself. It's becuase I didn't define the ID in the <input > tags.

I really ought to read up on jQuery - looks like it might prove useful!

BenWard
Newbie Poster
5 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Haha no problem of course, you are not to blame :). Stuff like this happens all the time, that's what makes it so damn handy to have a community at your disposal to help you out when you can't seem to figure out the problem by yourself.

Is there anything else you need help with?

minitauros
Posting Whiz
331 posts since Apr 2011
Reputation Points: 45
Solved Threads: 50
Skill Endorsements: 4

Hi,

The jsfiddle, as you have found, adds the onready handler. The reason I never use the cfform statements is that they seemed to require the same amount of work as simply adding the raw HTML equivalents. Sometimes, they require more work.

paulkd
Junior Poster
130 posts since Aug 2007
Reputation Points: 39
Solved Threads: 24
Skill Endorsements: 0

so i got a code like onMouseOver="this.bgColor=&#39;#fb2b27&#39;" how do i change it in to green color

safvansouri
Newbie Poster
1 post since May 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

You can use parse_url() to get the 'bits' and use the 'path' item. Just search in that.
Explode on '/' to isolate the city, region etc.
Then explode on ',' to get the 'key' and 'value'

diafol
Keep Smiling
Moderator
10,668 posts since Oct 2006
Reputation Points: 1,632
Solved Threads: 1,514
Skill Endorsements: 57
if(isset($_GET['category'])){
    $cat = $_GET['category'];
    if(isset($myarray[$cat])){
        echo $myarray[$cat];
    }else{
        echo "Not found in array";
    }
}    
diafol
Keep Smiling
Moderator
10,668 posts since Oct 2006
Reputation Points: 1,632
Solved Threads: 1,514
Skill Endorsements: 57

hai Bibek_NS,

in addition to the abouve suggested urls , go through the following links it may helps you in this regard

http://s3.envato.com/files/2526201/index.html

or

http://ruwix.com/simple-javascript-html-css-slider-progress-bar/

let me know if you have any doubts

happy coding

radhakrishna.p
Posting Whiz in Training
263 posts since Nov 2012
Reputation Points: 29
Solved Threads: 59
Skill Endorsements: 10

It doesn't look anything wrong in your code and it also works fine in my webform. It's hard to figure out the issue.

annaharris
Junior Poster in Training
67 posts since Apr 2013
Reputation Points: 0
Solved Threads: 6
Skill Endorsements: 0

What are you trying to do?
Can you please elaborate..

code_rum
Light Poster
49 posts since Feb 2013
Reputation Points: 8
Solved Threads: 8
Skill Endorsements: 3

It's good that you have resolved your issue. Congrats.

annaharris
Junior Poster in Training
67 posts since Apr 2013
Reputation Points: 0
Solved Threads: 6
Skill Endorsements: 0

If it already exists in your table, that means the record has been duplicated. First remove the duplicacy issue.

annaharris
Junior Poster in Training
67 posts since Apr 2013
Reputation Points: 0
Solved Threads: 6
Skill Endorsements: 0

Huh? There is no such animal(s) in SQL. What exactly are you trying to do? Give an example of your schema and the data it contains, and what you want to do for correlating that data to "category/sub-category".

rubberman
Posting Maven
2,581 posts since Mar 2010
Reputation Points: 365
Solved Threads: 307
Skill Endorsements: 52
shanky007
Newbie Poster
1 post since May 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.2890 seconds using 2.94MB