Search Results

Search found 837 results on 34 pages for 'the boy za'.

Page 3/34 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Java / Spring MVC 3 validation of an email address

    - by Tim
    I have a Java backend with Spring MVC and I am using validation in this way on my domain object for an email address: import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; ... @NotNull @Size(min = 1, max = 100) @Pattern(regexp="^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$") private String email; But all I get with these lines of code Set<ConstraintViolation<Person>> failures = validator.validate(personObject); ... Map<String, String> failureMessages = new HashMap<String, String>(); for (ConstraintViolation<Person> failure : failures) { failureMessages.put(failure.getPropertyPath().toString(), failure.getMessage()); System.out.println(failure.getPropertyPath().toString()+" - "+failure.getMessage()) } I get this on the console: email - must match "^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$" but I have as email address [email protected], so the regexp does not match. So I have two prolems: What's wrong here? And how can I define a error message on my own, because display this to the user, that is not a good thing :-) Thank you in advance for your help and Best Regards.

    Read the article

  • Common DataAnnotations in ASP.Net MVC2

    - by Scott Mayfield
    Howdy, I have what should be a simple question. I have a set of validations that use System.CompontentModel.DataAnnotations . I have some validations that are specific to certain view models, so I'm comfortable with having the validation code in the same file as my models (as in the default AccountModels.cs file that ships with MVC2). But I have some common validations that apply to several models as well (valid email address format for example). When I cut/paste that validation to the second model that needs it, of course I get a duplicate definition error because they're in the same namespace (projectName.Models). So I thought of removing the common validations to a separate class within the namespace, expecting that all of my view models would be able to access the validations from there. Unexpectedly, the validations are no longer accessible. I've verified that they are still in the same namespace, and they are all public. I wouldn't expect that I would have to have any specific reference to them (tried adding using statement for the same namespace, but that didn't resolve it, and via the add references dialog, a project can't reference itself (makes sense). So any idea why public validations that have simply been moved to another file in the same namespace aren't visible to my models? CommonValidations.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Text.RegularExpressions; namespace ProjectName.Models { public class CommonValidations { [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true, Inherited = true)] public sealed class EmailFormatValidAttribute : ValidationAttribute { public override bool IsValid(object value) { if (value != null) { var expression = @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"; return Regex.IsMatch(value.ToString(), expression); } else { return false; } } } } } And here's the code that I want to use the validation from: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Growums.Models; namespace ProjectName.Models { public class PrivacyModel { [Required(ErrorMessage="Required")] [EmailFormatValid(ErrorMessage="Invalid Email")] public string Email { get; set; } } }

    Read the article

  • Capistrano Error

    - by Casey van den Bergh
    I'm Running CentOS 5 32 bit version. This is my deploy.rb file on my local computer: #======================== #CONFIG #======================== set :application, "aeripets" set :scm, :git set :git_enable_submodules, 1 set :repository, "[email protected]:aeripets.git" set :branch, "master" set :ssh_options, { :forward_agent => true } set :stage, :production set :user, "root" set :use_sudo, false set :runner, "root" set :deploy_to, "/var/www/#{application}" set :app_server, :passenger set :domain, "aeripets.co.za" #======================== #ROLES #======================== role :app, domain role :web, domain role :db, domain, :primary => true #======================== #CUSTOM #======================== namespace :deploy do task :start, :roles => :app do run "touch #{current_release}/tmp/restart.txt" end task :stop, :roles => :app do # Do nothing. end desc "Restart Application" task :restart, :roles => :app do run "touch #{current_release}/tmp/restart.txt" end end And this the error I get on my local computer when I try to cap deploy. executing deploy' * executingdeploy:update' ** transaction: start * executing deploy:update_code' executing locally: "git ls-remote [email protected]:aeripets.git master" command finished in 1297ms * executing "git clone -q [email protected]:aeripets.git /var/www/seripets/releases/20111126013705 && cd /var/www/seripets/releases/20111126013705 && git checkout -q -b deploy 32ac552f57511b3ae9be1d58aec54d81f78f8376 && git submodule -q init && git submodule -q sync && export GIT_RECURSIVE=$([ ! \"git --version\" \\< \"git version 1.6.5\" ] && echo --recursive) && git submodule -q update --init $GIT_RECURSIVE && (echo 32ac552f57511b3ae9be1d58aec54d81f78f8376 > /var/www/seripets/releases/20111126013705/REVISION)" servers: ["aeripets.co.za"] Password: [aeripets.co.za] executing command ** [aeripets.co.za :: err] sh: git: command not found command finished in 224ms *** [deploy:update_code] rolling back * executing "rm -rf /var/www/seripets/releases/20111126013705; true" servers: ["aeripets.co.za"] [aeripets.co.za] executing command command finished in 238ms failed: "sh -c 'git clone -q [email protected]:aeripets.git /var/www/seripets/releases/20111126013705 && cd /var/www/seripets/releases/20111126013705 && git checkout -q -b deploy 32ac552f57511b3ae9be1d58aec54d81f78f8376 && git submodule -q init && git submodule -q sync && export GIT_RECURSIVE=$([ ! \"git --version`\" \< \"git version 1.6.5\" ] && echo --recursive) && git submodule -q update --init $GIT_RECURSIVE && (echo 32ac552f57511b3ae9be1d58aec54d81f78f8376 /var/www/seripets/releases/20111126013705/REVISION)'" on aeripets.co.za

    Read the article

  • Spring transactions not committing

    - by Clinton Bosch
    I am struggling to get my spring managed transactions to commit, could someone please spot what I have done wrong. All my tables are mysql InnonDB tables. My RemoteServiceServlet (GWT) is as follows: public class TrainTrackServiceImpl extends RemoteServiceServlet implements TrainTrackService { @Autowired private DAO dao; @Override public void init(ServletConfig config) throws ServletException { super.init(config); WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()); AutowireCapableBeanFactory beanFactory = ctx.getAutowireCapableBeanFactory(); beanFactory.autowireBean(this); } @Transactional(propagation= Propagation.REQUIRED, rollbackFor=Exception.class) public UserDTO createUser(String firstName, String lastName, String idNumber, String cellPhone, String email, int merchantId) { User user = new User(); user.setFirstName(firstName); user.setLastName(lastName); user.setIdNumber(idNumber); user.setCellphone(cellPhone); user.setEmail(email); user.setDateCreated(new Date()); Merchant merchant = (Merchant) dao.find(Merchant.class, merchantId); if (merchant != null) { user.setMerchant(merchant); } // Save the user. dao.saveOrUpdate(user); UserDTO dto = new UserDTO(); dto.id = user.getId(); dto.firstName = user.getFirstName(); dto.lastName = user.getLastName(); return dto; } The DAO is as follows: public class DAO extends HibernateDaoSupport { private String adminUsername; private String adminPassword; private String godUsername; private String godPassword; public String getAdminUsername() { return adminUsername; } public void setAdminUsername(String adminUsername) { this.adminUsername = adminUsername; } public String getAdminPassword() { return adminPassword; } public void setAdminPassword(String adminPassword) { this.adminPassword = adminPassword; } public String getGodUsername() { return godUsername; } public void setGodUsername(String godUsername) { this.godUsername = godUsername; } public String getGodPassword() { return godPassword; } public void setGodPassword(String godPassword) { this.godPassword = godPassword; } public void saveOrUpdate(ModelObject obj) { getHibernateTemplate().saveOrUpdate(obj); } And my applicationContext.xml is as follows: <context:annotation-config/> <context:component-scan base-package="za.co.xxx.traintrack.server"/> <!-- Application properties --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>file:${user.dir}/@propertiesFile@</value> </list> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${connection.dialect}</prop> <prop key="hibernate.connection.username">${connection.username}</prop> <prop key="hibernate.connection.password">${connection.password}</prop> <prop key="hibernate.connection.url">${connection.url}</prop> <prop key="hibernate.connection.driver_class">${connection.driver.class}</prop> <prop key="hibernate.show_sql">${show.sql}</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.c3p0.min_size">5</prop> <prop key="hibernate.c3p0.max_size">20</prop> <prop key="hibernate.c3p0.timeout">300</prop> <prop key="hibernate.c3p0.max_statements">50</prop> <prop key="hibernate.c3p0.idle_test_period">60</prop> </props> </property> <property name="annotatedClasses"> <list> <value>za.co.xxx.traintrack.server.model.Answer</value> <value>za.co.xxx.traintrack.server.model.Company</value> <value>za.co.xxx.traintrack.server.model.CompanyRegion</value> <value>za.co.xxx.traintrack.server.model.Merchant</value> <value>za.co.xxx.traintrack.server.model.Module</value> <value>za.co.xxx.traintrack.server.model.Question</value> <value>za.co.xxx.traintrack.server.model.User</value> <value>za.co.xxx.traintrack.server.model.CompletedModule</value> </list> </property> </bean> <bean id="dao" class="za.co.xxx.traintrack.server.DAO"> <property name="sessionFactory" ref="sessionFactory"/> <property name="adminUsername" value="${admin.user.name}"/> <property name="adminPassword" value="${admin.user.password}"/> <property name="godUsername" value="${god.user.name}"/> <property name="godPassword" value="${god.user.password}"/> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <!-- enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven transaction-manager="transactionManager"/> If I change the sessionFactory property to be autoCommit=true then my object does get persisited. <prop key="hibernate.connection.autocommit">true</prop>

    Read the article

  • C++ match string in file and get line number

    - by Corey
    I have a file with the top 1000 baby names. I want to ask the user for a name...search the file...and tell the user what rank that name is for boy names and what rank for girl names. If it isn't in boy names or girl names, it tells the user it's not among the popular names for that gender. The file is laid out like this: Rank Boy-Names Girl-Names 1 Jacob Emily 2 Michael Emma . . . Desired output for input Michael would be: Michael is 2nd most popular among boy names. If Michael is not in girl names it should say: Michael is not among the most popular girl names Though if it was, it would say: Micheal is (rank) among girl names The code I have so far is below.. I can't seem to figure it out. Thanks for any help. #include <iostream> #include <fstream> #include <string> #include <cctype> using namespace std; void find_name(string name); int main(int argc, char **argv) { string name; cout << "Please enter a baby name to search for:\n"; cin >> name; /*while(!(cin>>name)) { cout << "Please enter a baby name to search for:\n"; cin >> name; }*/ find_name(name); cin.get(); cin.get(); return 0; } void find_name(string name) { ifstream input; int line = 0; string line1 = " "; int rank; string boy_name = ""; string girl_name = ""; input.open("/<path>/babynames2004.rtf"); if (!input) { cout << "Unable to open file\n"; exit(1); } while(input.good()) { while(getline(input,line1)) { input >> rank >> boy_name >> girl_name; if (boy_name == name) { cout << name << " is ranked " << rank << " among boy names\n"; } else { cout << name << " is not among the popular boy names\n"; } if (girl_name == name) { cout << name << " is ranked " << rank << " among girl names\n"; } else { cout << name << " is not among the popular girl names\n"; } } } input.close(); }

    Read the article

  • ASP.Net MVC: "Random" URLs getting generated by URL.Action

    - by Daniel Magliola
    I have 2 very similar routes, just because i'm trying to generate two different URLs for the same resource (same Controller/Action), and both are very similar. These are the routes definitions: routes.MapRoute("Post2.Mp3", "sites/{siteSlug}/post/{brand}/aconstant-{slug}.mp3", new { controller = "Posts", action = "Mp3" }, new { siteSlug = @"[A-Za-z0-9-_]+", slug = @"[^(aconstant\-)][A-Za-z0-9-_]+", brand = @"[A-Za-z0-9-_]+" }); routes.MapRoute("Post.Mp3", "sites/{siteSlug}/post/{slug}.mp3", new { controller = "Posts", action = "Mp3" }, new { siteSlug = @"[A-Za-z0-9-_]+", slug = @"[A-Za-z0-9-_]+" }); "brand" is going to be my site name, which is the same as "aconstant" in those routes. Now, if I try this: Url.Action("ShowMp3", "Posts", new { siteSlug = post.Site.Slug, slug = post.Slug, origin = "origfeedwithaudio", brand = "aconstant" }) sometimes I get the URL I expect: /sites/site-Name/post/aconstant/aconstant-post-Name.mp3 but sometimes, I get this: /sites/site-Name/post/post-Name.mp3?brand=aconstant By sometimes, I mean that different sets of "slugs" give me one or the other. I haven't seen the same set of slugs give me different URLs. I haven't found any reasonable rule for when i'm getting one or the other, it seems random. What is going on here? How can I be getting different URLs based on esentially the same arguments? Thanks! Daniel

    Read the article

  • C++: posix regex error reporting?

    - by Helltone
    I'm writing a small C++ program that parses some strings. I chose to use C's regex.h because I only need POSIX Extended Syntax and I'm concerned with portability. However, I've just noticed that when regexec fails to match, it returns != 0 and I have no idea of what was wrong :-(. I expected to be able to display at least a small message like: line:col: Syntax error or giig sdoigosdigo* sodfg ^ Syntax error Is there a way to know which character did not match? Should I use boost:regex instead? For reference, my regex is: "^" "[ ;\t\n]*" "(" // (1) identifier "[a-zA-Z_][a-zA-Z0-9_]*" ")" "[ \t]*" "(" // (2) non-marking "\[" "(" // (3) non-marking "[ \t]*" "(" // (4..n-1) argument "[a-zA-Z0-9_]+" ")" "[ \t]*" "," ")*" "[ \t]*" "(" // (n) last argument "[a-zA-Z0-9_]+" ")" "]" ")?" "[ \t\n]*" ";" Which matches for instance blablabla[arg1, arg2];

    Read the article

  • Regex is capturing the whole string

    - by M28
    I am using the following regex: (public|private +)?function +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)} To match the following string: public function messenger(text){ sendMsg(text); } private function sendMsg(text){ alert(text); } (There is no line breaks in the string, they are converted to whitespaces before the regex runs) I wanted it to capture both functions, but it is capturing: $1: "" $2: "messenger" $3: "text" $4: " sendMsg(text); } private function sendMsg(text){ alert(text); " By the way, I am using Javascript.

    Read the article

  • rails application on production not working

    - by Steven
    i have a rails application on production which is running using mongrel, I can successfully start the mogrel for the application but when i try to access the application on the URL it is not responding... it is just hanging. This is the mongrel log... but when I hit xxx.xxx.xxx.xx:3001 it is not showing the website but on developent is working fine. ** Starting Mongrel listening at 0.0.0.0:3001 ** Initiating groups for "name.co.za":"name.co.za". ** Changing group to "name.co.za". ** Changing user to "name.co.za". ** Starting Rails with production environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM = stop. USR2 = restart. INT = stop (no restart). ** Rails signals registered. HUP = reload (without restart). It might not work well. ** Mongrel 1.1.5 available at 0.0.0.0:3001 ** Writing PID file to /home/name.co.za/shared/log/mongrel.pid

    Read the article

  • ctags doesn't undestand -e option (no exuberant tags option)

    - by Thr4wn
    When I type ctags -e it returns an error saying it doesn't know that command line option. I thought it should know about exuberant tags because etags works on cli. Also, I recieve the following error: ctags: unrecognized option --langdef=arc and I have the following in my ~/.ctags file: --langdef=arc --langmap=arc:.arc --regex-arc=/^\(def ([a-zA-Z1-9_*\/<>-]+)/\1/ --regex-arc=/^\(= ([a-zA-Z1-9_*\/<>-]+)/\1/ --regex-scheme=/^\(xdef ([a-zA-Z1-9_*\/<>-]+)/\1/

    Read the article

  • ZipArchive on the iPhone unzips files but they are empty

    - by user345131
    I'm trying to use ZipArchive on the iPhone to unzip a simple text file. It returns with no error but the file is empty. I would love to know why this doesn't work. I am using the following methods: -(void)alert:(NSString*)message { UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"" message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [myAlert show]; [myAlert release]; } -(void)unzip { NSString *sourcepath = [[NSBundle mainBundle] pathForResource:@"secret" ofType:@"zip"]; NSString*filename = @"secret.txt"; NSArray *docPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *destinationpath = [docPaths objectAtIndex: 0]; if (filename != nil ) destinationpath = [destinationpath stringByAppendingPathComponent: filename]; ZipArchive* za = [[ZipArchive alloc] init]; if( [za UnzipOpenFile:sourcepath Password:@""] ) { BOOL ret = [za UnzipFileTo:destinationpath overWrite:YES]; if( NO==ret ) [self alert:@"Problem"]; else [self alert:@"Success"]; [za UnzipCloseFile]; } [za release]; NSString *test = [[NSString alloc] initWithContentsOfFile:destinationpath encoding:NSASCIIStringEncoding error:nil]; [self alert:test]; }

    Read the article

  • is it the right reqular expression

    - by girish
    i have following regular expression but it's not working properly it takes only three values after @ sign but i want it to be any number length "/^[a-zA-Z0-9_.-]+\@([a-zA-Z0-9-]+.)+[a-zA-Z0-9]{2,4}$/" this@thi This is validated this@this It is not validating this expression Can you please tell me what's the problem with the expression... Thanks

    Read the article

  • after .htaccess url rewrite, cannot perform logoff in some of the url rewrited page

    - by Patrick
    Recently, I was doing .htaccess url rewrite, make all my php url into html, in some page, the logout button wont work properly. for example, in page ‘quotedetails/Q9999.html’ (rewrited from ‘quotedetails.php?quoteID=Q9999'), when I click logout button in this page, it wont do the trick, but when i use the old php url of this page, it works again, other rewrited pages like index.html (index.php), search.html(search.php), all works perfectly. I use firebug to debug, after I click the logout button, it stays in the same page without redirect me to the index.html, but I saw the the ‘logoff’ params has been passed through, but just dont let me logout and redirect to index page. I’ve changed all the relavent file path to absolute path, still no luck…..help please. I’ve also noticed from firebug, that page cannot get the redirect ‘location’ as I tried in other pages, their response headers come with ‘location: index.html’, but in that no-workin-page, there is no such line called ‘location: index.html’ in its response headers. Here is my .htaccess file, no-workin-pages are related to the first four ReweiteRules Options +FollowSymlinks RewriteEngine on RewriteRule ^reps/all,all.html$ rep.php?repID=all&repName=all RewriteRule ^reps/([A-Z]+),([A-Za-z\sA-Za-z]+).html$ rep.php?repID=$1&repName=$2 RewriteRule ^reps/([A-Za-z]+),([A-Za-z\sA-Za-z]+),([0-9]+).html$ rep.php?repID=$1repName=$2&page=$3 RewriteRule ^quotedetails/(Q[0-9]+).html$ quotedetails.php?quoteID=$1 RewriteRule ^index.html$ index.php RewriteRule ^addquote.html$ addquote.php RewriteRule ^search.html$ search.php RewriteRule ^viewall.html$ viewall.php RewriteRule ^howto.html$ howto.php

    Read the article

  • Rewritecond multiple RewriteRule

    - by swamprunner7
    How can i rewrite these: RewriteCond %{HTTP_HOST} ^(www\.)?([0-9a-zA-Z\-_]+)\.test\.com$ [NC] RewriteRule ^$ /feeds.php?act=user&login=%2 [L] RewriteCond %{HTTP_HOST} ^(www\.)?([0-9a-zA-Z\-_]+)\.test\.com$ [NC] RewriteRule ^(faves)$ /feeds.php?act=faves&login=%2 [L] to something like: RewriteCond %{HTTP_HOST} ^(www\.)?([0-9a-zA-Z\-_]+)\.test\.com$ [NC] RewriteRule ^$ /feeds.php?act=user&login=%2 [L] RewriteRule ^(faves)$ /feeds.php?act=faves&login=%2 [L] Is it posible to apply RewriteCond for multiple rules?

    Read the article

  • UNIX script to parse Zone file (is this the best code?)

    - by Steve
    Hi, FOund the following on: http://mike.murraynet.net/2009/08/23/parsing-the-verisign-zone-file-with-os-x/ Can unix-masters have a look at it and see if its the best possible way to gather the unique domainsnames in a zone file? For .NET domains: grep “^[a-zA-Z0-9-]+ NS .” net.zone|sed “s/NS .//”|uniq netdomains.txt For .COM domains: grep “^[a-zA-Z0-9-]+ NS .” com.zone|sed “s/NS .//”|uniq comdomains.txt For .EDU domains: grep “^[a-zA-Z0-9-]+ NS .” edu.zone|sed “s/NS .//”|uniq edudomains.txt

    Read the article

  • match 'article' in url RewriteRule

    - by daniel Crabbe
    hello there. building a site which has content for each section. urls range from; /work/ /work/print/ /work/print/folders etc. however, at any point a user can click on an article so; /work/article/1066 /work/print/article/1066 /work/print/folders/article/1066 using .htaccess i need to detect when there is 'article' in the url and set some different variables. RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/$ sets index.php?level1=$1&level2=$2&level3=$3&level4=$4 but if 'article/([0-9-]+)' is in the url, say /work/print/article/1066 return index.php?level1=$1&level2=$2&articleID=1066 basically the amount of levels will always be different but i'd like to return those as needed. another example would /work/print/folder/archive/article/1066 return index.php?level1=$1&level2=$2&level3=$3&level4=$4&articleID=1066 any help appreciated! Dan

    Read the article

  • PHP Multiple User Login Form - Navigation to Different Pages Based on Login Credentials

    - by Zulu Irminger
    I am trying to create a login page that will send the user to a different index.php page based on their login credentials. For example, should a user with the "IT Technician" role log in, they will be sent to "index.php", and if a user with the "Student" role log in, they will be sent to the "student/index.php" page. I can't see what's wrong with my code, but it's not working... I'm getting the "wrong login credentials" message every time I press the login button. My code for the user login page is here: <?php session_start(); if (isset($_SESSION["manager"])) { header("location: http://www.zuluirminger.com/SchoolAdmin/index.php"); exit(); } ?> <?php if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["role"])) { $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]); $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]); $role = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["role"]); include "adminscripts/connect_to_mysql.php"; $sql = mysql_query("SELECT id FROM Users WHERE username='$manager' AND password='$password' AND role='$role' LIMIT 1"); $existCount = mysql_num_rows($sql); if (($existCount == 1) && ($role == 'IT Technician')) { while ($row = mysql_fetch_array($sql)) { $id = $row["id"]; } $_SESSION["id"] = $id; $_SESSION["manager"] = $manager; $_SESSION["password"] = $password; $_SESSION["role"] = $role; header("location: http://www.zuluirminger.com/SchoolAdmin/index.php"); } else { echo 'Your login details were incorrect. Please try again <a href="http://www.zuluirminger.com/SchoolAdmin/index.php">here</a>'; exit(); } } ?> <?php if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["role"])) { $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]); $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]); $role = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["role"]); include "adminscripts/connect_to_mysql.php"; $sql = mysql_query("SELECT id FROM Users WHERE username='$manager' AND password='$password' AND role='$role' LIMIT 1"); $existCount = mysql_num_rows($sql); if (($existCount == 1) && ($role == 'Student')) { while ($row = mysql_fetch_array($sql)) { $id = $row["id"]; } $_SESSION["id"] = $id; $_SESSION["manager"] = $manager; $_SESSION["password"] = $password; $_SESSION["role"] = $role; header("location: http://www.zuluirminger.com/SchoolAdmin/student/index.php"); } else { echo 'Your login details were incorrect. Please try again <a href="http://www.zuluirminger.com/SchoolAdmin/index.php">here</a>'; exit(); } } ?> And the form that the data is pulled from is shown here: <form id="LoginForm" name="LoginForm" method="post" action="http://www.zuluirminger.com/SchoolAdmin/user_login.php"> User Name:<br /> <input type="text" name="username" id="username" size="50" /><br /> <br /> Password:<br /> <input type="password" name="password" id="password" size="50" /><br /> <br /> Log in as: <select name="role" id="role"> <option value="">...</option> <option value="Head">Head</option> <option value="Deputy Head">Deputy Head</option> <option value="IT Technician">IT Technician</option> <option value="Pastoral Care">Pastoral Care</option> <option value="Bursar">Bursar</option> <option value="Secretary">Secretary</option> <option value="Housemaster">Housemaster</option> <option value="Teacher">Teacher</option> <option value="Tutor">Tutor</option> <option value="Sanatorium Staff">Sanatorium Staff</option> <option value="Kitchen Staff">Kitchen Staff</option> <option value="Parent">Parent</option> <option value="Student">Student</option> </select><br /> <br /> <input type="submit" name = "button" id="button" value="Log In" onclick="javascript:return validateLoginForm();" /> </h3> </form> Once logged in (and should the correct page be loaded, the validation code I have at the top of the script looks like this: <?php session_start(); if (!isset($_SESSION["manager"])) { header("location: http://www.zuluirminger.com/SchoolAdmin/user_login.php"); exit(); } $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); $role = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["role"]); include "adminscripts/connect_to_mysql.php"; $sql = mysql_query("SELECT id FROM Users WHERE username='$manager' AND password='$password' AND role='$role' LIMIT 1"); $existCount = mysql_num_rows($sql); if ($existCount == 0) { header("location: http://www.zuluirminger.com/SchoolAdmin/index.php"); exit(); } ?> Just so you're aware, the database table has the following fields: id, username, password and role. Any help would be greatly appreciated! Many thanks, Zulu

    Read the article

  • Making links clickable from comments in php

    - by neat
    im trying to create functions that will give my chat clickable links.... here are the functions i've created <?php //makes links starting with http clickable function makehttpclickable($text){ return preg_replace('!(((f|ht)tp://)[-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $text); } //makes links starting www. http clickable function clickywww($www){ return preg_replace('!((www)[-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $www); } /function that gives me an error! function clickydotcom($noob){ return preg_replace('!([-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)(\.com)!i'.'!([-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)(\.com)!f', '<a href="$1.com$f">$1.com</a>', $noob); } I've been getting an unkown modifier error. Warning: preg_replace() [function.preg-replace]: Unknown modifier '!' So Anyways any help would be nice on how i can make all types of links clickable

    Read the article

  • How to allow all except part 1 and part 2 ?

    - by Stackfan
    This allows me to get easyly dynamic input variables instead of putting a static prefix like /en/etcetcetc, but the problem is all controllers are blocked. Everything goes to index/index. Question: How can i tell this rule allow evertying as it is now, but do not track if it contains http://site.com/donotcatch/me and http://site.com/iamnotbelongstodynamic1/blabla protected function _initRoutes() { ... $dynamic1 = new Zend_Controller_Router_Route( '/:variable0/:variable1', array( 'controller' => 'index', 'action' => 'index'), array( 'variable0' => '^[a-zA-Z0-9_]*$', 'variable1' => '^[a-zA-Z0-9_]*$', ) ); Follow up: Normally, i always belive yes we can, so, we can do that like this where dynamic1 does not the inter-fare with my other static controllers: // http://site/yeswecan/blabla // variable0 = yeswecan // variable1 = blabla $dynamic1 = new Zend_Controller_Router_Route( '/:variable0/:variable1', array( 'controller' => 'index', 'action' => 'index'), array( 'variable0' => '^[a-zA-Z]*$', 'variable1' => '^[a-z0-9_]*$', ) ); // http://site/ajax/whatever... // solves it $dynamic2 = new Zend_Controller_Router_Route( '/ajax/:variable0', array( 'controller' => 'ajax', 'action' => '' ), array( 'variable0' => '^[a-zA-Z0-9_]*$', ) ); // http://site/order/whatever... // solves it $dynamic3 = new Zend_Controller_Router_Route( '/order/:variable0', array( 'controller' => 'order', 'action' => ''), array( 'variable0' => '^[a-zA-Z0-9_]*$', ) ); Note: Still the controllers are getting failed for example http://site/ajax/whatever always goes to /ajax/index where i wanted to send it as /ajax/user-inserted-value How can i fix the $dynamic2 and $dynamic3 by keeping $dynamic1 ??

    Read the article

  • simple method that checks text is email with regular expression

    - by user223863
    Can't believe how difficult this seems to be all I want to is to validate a user inout using javascript to make sure that it is an email address. But can't get it to work: I am using: //validates a regulaer expression Utilities2.prototype.validateEmail = function(stringToValidateArg) { alert('about to check regexp'); var regExpPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; alert(regExpPattern.test(stringToValidateArg)); } But this always returns false, any ideas why is it because of the regular expression?

    Read the article

  • Validate format of email in rails.

    - by piemesons
    validates_format_of :email, :with => /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/, :message => "is missing or invalid" Please let me know where is the problem? Is regular expression is wrong?

    Read the article

  • how to read only english characters

    - by ralph
    I am reading a file that sometimes has chinese and characters of languages other than english. How can I write a regex that only reads english words/letters? should it just be /^[a-zA-Z]+/ ? If I do the above then words like eété will still be picked but I don't want them to be picked: "été".match(/^[a-zA-Z]+/) => #nil good I didnt want that word "eété".match(/^[a-zA-Z]+/) => #not nil tricked into picking something i did not want

    Read the article

  • problem in split text by php

    - by moustafa
    Hi Team, I need to split the below contents by using the mobile number and email id. If the mobile number and email id found the content is splitted into some blocks. I am using the preg_match_all to check the mobile number and email id. For example : The Given Content: WANTED B'ful Non W'kingEdu Fair Girl for MBA 28/175 H'some Fair Mangal Gotra Boy Well estd. B'ness HI Income Status family Email: [email protected] PQM4 h'some Convent Educated B.techIIT, MS/28/5'9" Wkg in US frm repu fmlyseek b'ful,tall g i r l . Mo:09893029129 Em:[email protected] 5' 2" to 5' 5" b'ful QLFD girl for h a n d s o m e 5' 8" BPT (I) MPT G.Medalist (AUS) wkg in Australia Physiotherapist boy from V.respectable fmly of Surat / DeUli. Tel: 09825147614. EmaU: [email protected] The Desired output should be: 1st block: WANTED B'ful Non W'kingEdu Fair Girl for MBA 28/175 H'some Fair Mangal Gotra Boy Well estd. B'ness HI Income Status family Email: [email protected] 2nd block: PQM4 h'some Convent Educated B.techIIT, MS/28/5'9" Wkg in US frm repu fmlyseek b'ful,tall g i r l . Mo:09893029129 Em:[email protected] 3rd block: 5' 2" to 5' 5" b'ful QLFD girl for h a n d s o m e 5' 8" BPT (I) MPT G.Medalist (AUS) wkg in Australia Physiotherapist boy from V.respectable fmly of Surat / DeUli. Tel: 09825147614. EmaU: [email protected] I do no how to split it.I need some logics. When i am using preg_match_all when ever a mobile number found i inserted a new line and split the blocks.But email id is splitted independently.

    Read the article

  • Using Find/Replace with regular expressions inside a SSIS package

    - by jamiet
    Another one of those might-be-useful-again-one-day-so-I’ll-share-it-in-a-blog-post blog posts I am currently working on a SQL Server Integration Services (SSIS) 2012 implementation where each package contains a parameter called ETLIfcHist_ID: During normal execution this will get altered when the package is executed from the Execute Package Task however we want to make sure that at deployment-time they all have a default value of –1. Of course, they tend to get changed during development so I wanted a way of easily changing them all back to the default value. Opening up each package in turn and editing them was an option but given that we have over 40 packages and we might want to carry out this reset fairly frequently I needed a more automated method so I turned to Visual Studio’s Find/Replace… feature Of course, we don’t know what value will be in that parameter so I can’t simply search for a particular value; hence I opted to use a regular expression to identify the value to be change. In the rest of this blog post I’ll explain how to do that. For demonstration purposes I have taken the contents of a .dtsx file and stripped out everything except the element containing the parameters (<DTS:PackageParameters>), if you want to play along at home you can copy-paste the XML document below into a new XML file and open it up in Visual Studio: <?xml version="1.0"?> <DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts">   <DTS:PackageParameters>     <DTS:PackageParameter       DTS:CreationName=""       DTS:DataType="3"       DTS:Description="InterfaceHistory_ID: used for Lineage"       DTS:DTSID="{635616DB-EEEE-45C8-89AA-713E25846C7E}"       DTS:ObjectName="ETLIfcHist_ID">       <DTS:Property         DTS:DataType="3"         DTS:Name="ParameterValue">VALUE_TO_BE_CHANGED</DTS:Property>     </DTS:PackageParameter>     <DTS:PackageParameter       DTS:CreationName=""       DTS:DataType="3"       DTS:Description="Some other description"       DTS:DTSID="{635616DB-EEEE-45C8-89AA-713E25845C7E}"       DTS:ObjectName="SomeOtherObjectName">       <DTS:Property         DTS:DataType="3"         DTS:Name="ParameterValue">SomeOtherValue</DTS:Property>     </DTS:PackageParameter>   </DTS:PackageParameters> </DTS:Executable> We are trying to identify the value of the parameter whose name is ETLIfcHist_ID – notice that in the XML document above that value is VALUE_TO_BE_CHANGED. The following regular expression will find the appropriate portion of the XML document: {\<DTS\:PackageParameter[\n ]*DTS\:CreationName="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:DataType="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:Description="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:DTSID="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:ObjectName="ETLIfcHist_ID"\>[\n ]*\<DTS\:Property[\n ]*DTS\:DataType="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:Name="ParameterValue"\>}[A-Za-z0-9\:_\{\}- ]*{\<\/DTS\:Property\>} I have highlighted the name of the parameter that we’re looking for. I have also highlighted two portions identified by pairs of curly braces “{…}”; these are important because they pick out the two portions either side of the value I want to replace, in other words the portions highlighted here: <DTS:PackageParameters>     <DTS:PackageParameter       DTS:CreationName=""       DTS:DataType="3"       DTS:Description="InterfaceHistory_ID: used for Lineage"       DTS:DTSID="{635616DB-EEEE-45C8-89AA-713E25846C7E}"       DTS:ObjectName="ETLIfcHist_ID">       <DTS:Property         DTS:DataType="3"         DTS:Name="ParameterValue">VALUE_TO_BE_CHANGED</DTS:Property>     </DTS:PackageParameter> Those sections in the curly braces are termed tag expressions and can be identified in the replace expression using a backslash and a number identifying which tag expression you’re referring to according to its ordinal position. Hence, our replace expression is simply: \1-1\2 We’re saying the portion of our file identified by the regular expression should be replaced by the first curly brace section, then the literal –1, then the second curly brace section. Make sense? Give it a go yourself by plugging those two expressions into Visual Studio’s Find and Replace dialog. If you set it to look in “All Open Documents” then you can open up the code-behind of all your packages and change all of them at once. The Find and Replace dialog will look like this: That’s it! I realise that not everyone will be looking to change the value of a parameter but hopefully I have shown you a technique that you can modify to work for your own scenario. Given that this blog post is, y’know, on the web I have no doubt that someone is going to find a fault with my find regex expression and if that person is you….that’s OK. Let me know about it in the comments below and perhaps we can work together to come up with something better! Note that some parameters may have a different set of properties (for example some, but not all, of my parameters have a DTS:Required attribute) so your find regular expression may have to change accordingly. When researching this I found the following article to be invaluable: Visual Studio Find/Replace Regular Expression Usage @Jamiet

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >