Jump to content

If field is empty help


herghost

Recommended Posts

Hi all,

 

I have this:

<?php
session_start();
include('login/functions.php');
$username = $_SESSION['username'];
$check = mysql_query("SELECT email FROM user_profile WHERE username = '$username'");
$a = mysql_fetch_field($check);
if(empty($a))
{
header('Location: complete.php');
}


?>

 

However if the field is empty, ie no email address for user then nothing happens?

 

Am going about this the right way?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/237378-if-field-is-empty-help/
Share on other sites

Same problem :(

 

The row itself will exist, as its created on first login (twitter oauth)

 

However on first login email will not be filled in the row.

 

I have

<?php

session_start();

include('login/functions.php');

$username = $_SESSION['username'];

$check = mysql_query("SELECT email FROM user_profile WHERE username = '$username'");

$a = mysql_num_rows($check);

if(!$check)

{

echo mysql_error();

}

if(empty($a))

{

header('Location: complete.php');

}

 

 

?>

 

The query doesnt fail so its not that :(

 

Perfect! Thanks:)

 

<?php
session_start();
include('login/functions.php');
$username = $_SESSION['username'];
$check = mysql_query("SELECT email FROM user_profile WHERE username = '$username'");
$num = mysql_result($check, 0);
if(empty($num))
{
header('location: complete.php');
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.