[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Split

Posted on 2004-10-22
3
Medium Priority
?
179 Views
Last Modified: 2012-05-05
How do I split a line like say I put

$result = @mysql_query("select Email from Login where `username`='" . $_POST['Text1'] . "' and `Password`='" . $_POST['Text2'] . "'");


but I want the above statement split in two like instead of having it one sentence......how to do ti


Moiz
0
Comment
Question by:Moizsaif123
3 Comments
 
LVL 2

Accepted Solution

by:
TheUnkind earned 240 total points
ID: 12387305
if you mean this whole sentence

$result = @mysql_query("select Email from Login where `username`='" . $_POST['Text1'] . "' and `Password`='" . $_POST['Text2'] . "'");

>>you can do this:
$result = @mysql_query("select Email from Login where
  `username`='" . $_POST['Text1'] . "' and `Password`='" . $_POST['Text2'] . "'");
0
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 80 total points
ID: 12387437
$query = 'select Email from Login'.
              ' where'.
              ' `username`="' . addSlashes($_POST['Text1']) . '"'.
              ' and '.
              ' `Password`="' .md5($_POST['Text2']).'"';

Or

$query = 'select Email from Login
               where
               `username`="' . addSlashes($_POST['Text1']) . '"
               and
               `Password`="' .md5($_POST['Text2']).'"';


$result = @mysql_query($query);

Regards

-r-
0
 
LVL 7

Assisted Solution

by:BenMorel
BenMorel earned 80 total points
ID: 12391159
OR :
===

$Query = "SELECT Email FROM Login ";
$Query.= "WHERE `username` = '{$_POST['Text1']}' ";
$Query.= "AND `Password` = '{$_POST['Text2']}'";

... But it may be a little slower (in theory...) so prefer :
===================================

$Query = "SELECT Email FROM Login " .
    "WHERE `username` = '{$_POST['Text1']}' " .
    "AND `Password` = '{$_POST['Text2']}'";


Don't forget to addslashes() you variables if you don't have magic_quotes_gpc enabled !
(This might be a security hole...)

See ya
Ben
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month20 days, 13 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question